File: tag.rb

package info (click to toggle)
ruby-locale 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 444 kB
  • ctags: 293
  • sloc: ruby: 3,203; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 822 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
=begin
  tag.rb - Locale::Tag module

  Copyright (C) 2008,2009  Masao Mutoh
 
  You may redistribute it and/or modify it under the same
  license terms as Ruby.
=end

require 'locale/tag/simple'
require 'locale/tag/irregular'
require 'locale/tag/common'
require 'locale/tag/rfc'
require 'locale/tag/cldr'
require 'locale/tag/posix'

module Locale

  # Language tag / locale identifiers.
  module Tag
    module_function
    # Parse a language tag/locale name and return Locale::Tag
    # object.
    # * tag: a tag as a String. e.g.) ja-Hira-JP
    # * Returns: a Locale::Tag subclass.
    def parse(tag)
      # Common is not used here.
      [Simple, Common, Rfc, Cldr, Posix].each do |parser|
        ret = parser.parse(tag)
        return ret if ret
      end
      Locale::Tag::Irregular.new(tag)
    end
  end
end