Create Locale::Tag::Cldr.
variants should be upcase.
# File lib/locale/tag/cldr.rb, line 58 def initialize(language, script = nil, region = nil, variants = [], extensions = {}) @extensions = extensions super(language, script, region, variants.map{|v| v.upcase}) end
Parse the language tag and return the new Locale::Tag::CLDR.
# File lib/locale/tag/cldr.rb, line 31 def parse(tag) if tag =~ %r\APOSIX\Z/ # This is the special case of POSIX locale but match this regexp. nil elsif tag =~ TAG_RE lang, script, region, subtag = $1, $2, $3, $4 extensions = {} subtag.scan(%r#{EXTENSION}/).each{|v| subtag.sub!(v, "") key, type = v.split("=") extensions[key] = type } variants = subtag.scan(%r#{VARIANT}/).collect{|v| v[0].upcase} ret = self.new(lang, script, region, variants, extensions) ret.tag = tag ret else nil end end
Sets the extensions as an Hash.
# File lib/locale/tag/cldr.rb, line 65 def extensions=(val) clear @extensions = val end