Locale tag class for POSIX locale
ja
ja_JP
ja_JP.UTF-8
ja_JP.UTF-8@Osaka
C/POSIX (-> en_US)
# File lib/locale/tag/posix.rb, line 27 27: def initialize(language, region = nil, charset = nil, modifier = nil) 28: @charset, @modifier = charset, modifier 29: super(language, region) 30: end
# File lib/locale/tag/posix.rb, line 32 32: def self.parse(tag) 33: if tag =~ /^(C|POSIX)$/ 34: ret = self.new("en", "US") 35: ret.tag = tag 36: ret 37: elsif tag =~ TAG_RE 38: ret = self.new($1, $2, $3, $4) 39: ret.tag = tag 40: ret 41: else 42: nil 43: end 44: end
Returns an Array of tag-candidates order by priority. Use Locale.candidates instead of this method.
# File lib/locale/tag/posix.rb, line 71 71: def candidates 72: [self.class.new(language, region, charset, modifier), #ja_JP.UTF-8@Modifier 73: self.class.new(language, region, charset), #ja_JP.UTF-8 74: self.class.new(language, region, nil, modifier), #ja_JP@Modifier 75: self.class.new(language, region, nil, nil), #ja_JP@Modifier 76: self.class.new(language, nil, charset, modifier), #ja.UTF-8@Modifier 77: self.class.new(language, nil, charset), #ja.UTF-8 78: self.class.new(language, nil, nil, modifier), #ja@Modifier 79: self.class.new(language)] #ja 80: end
Set the charset.
# File lib/locale/tag/posix.rb, line 58 58: def charset=(val) 59: clear 60: @charset = val 61: end
Set the modifier as a String
# File lib/locale/tag/posix.rb, line 64 64: def modifier=(val) 65: clear 66: @modifier = val 67: end
Returns the language tag.
<language>_<COUNTRY>.<CHARSET>@<MODIFIER> (e.g.) "ja_JP.EUC-JP@Modifier"
# File lib/locale/tag/posix.rb, line 49 49: def to_s 50: s = @language.dup 51: s << "_#{@region}" if @region 52: s << ".#{@charset}" if @charset 53: s << "@#{@modifier}" if @modifier 54: s 55: end
A modifier is converted to a variant. If the modifier is less than 5 characters, it is not canonical value.
# File lib/locale/tag/posix.rb, line 85 85: def convert_to(klass) 86: if klass == Simple 87: super 88: elsif klass == Posix 89: klass.new(language, region, charset, modifier) 90: else 91: klass.new(language, nil, region, modifier ? [modifier] : []) 92: end 93: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.