Module: Locale::Tag

Includes:
Util::Memoizable
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

Constant Summary

Constants included from Util::Memoizable

Util::Memoizable::MEMOIZED_IVAR

Class Method Summary collapse

Methods included from Util::Memoizable

#_memoize, #_memoize_dup, #clear, #freeze, #freeze_without_memoizable, #memoize, #memoize_clear, #memoize_dup, #memoize_impl

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.



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

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