Create Locale::Tag::Cldr.
variants should be upcase.
# File lib/locale/tag/cldr.rb, line 56 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 30 def parse(tag) if tag =~ /\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(/#{EXTENSION}/).each{|v| subtag.sub!(v, "") key, type = v.split("=") extensions[key] = type } variants = subtag.scan(/#{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 63 def extensions=(val) @extensions = val end
Returns the language tag. (e.g.) “ja_Hira_JP_VARIANT1_VARIANT2@foo1=var1;foo2=var2”
This is used in internal only. Use to_s instead.
# File lib/locale/tag/cldr.rb, line 87 def to_string s = super if @extensions.size > 0 s << "@" << @extensions.to_a.sort.map{|k, v| "#{k}=#{v}"}.join(";") end s end