Module: Locale::Tag

Defined in:
lib/locale/tag.rb,
lib/locale/tag/rfc.rb,
lib/locale/tag/cldr.rb,
lib/locale/tag/posix.rb,
lib/locale/tag/common.rb,
lib/locale/tag/simple.rb,
lib/locale/tag/irregular.rb

Overview

Language tag / locale identifiers.

Defined Under Namespace

Classes: Cldr, Common, Irregular, Posix, Rfc, Simple

Class Method Summary collapse

Class Method Details

.parse(tag) ⇒ Object

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.



26
27
28
29
30
31
32
33
# File 'lib/locale/tag.rb', line 26

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