Class Locale::Tag::Common
In: lib/locale/tag/common.rb
Parent: Simple

Common Language tag class for Ruby. Java and MS Windows use this format.

  • ja (language: RFC4646)
  • ja_JP (country: RFC4646(2 alpha or 3 digit))
  • ja-JP
  • ja_Hira_JP (script: 4 characters)
  • ja-Hira-JP
  • ja_Hira_JP_MOBILE (variants: more than 2 characters or 3 digit)
  • ja_Hira_JP_MOBILE_IPHONE (2 variants example)

Methods

candidates   new   parse   script=   variants=  

Constants

LANGUAGE = "(#{ALPHA}{2,3}|#{ALPHA}{4}|#{ALPHA}{5,8})"
SCRIPT = "(#{ALPHA}{4})"
VARIANT = "(#{ALPHANUM}{3,}|#{DIGIT}#{ALPHANUM}{3})"
TAG_RE = /\A#{LANGUAGE}(?:[-_]#{SCRIPT})? (?:[-_]#{REGION})?((?:[-_]#{VARIANT})*)\Z/ix

Attributes

script  [R] 
variants  [R] 

Public Class methods

Parse the language tag and return the new Locale::Tag::Common.

Public Instance methods

Returns an Array of tag-candidates order by priority. Use Locale.candidates instead of this method.

Locale::Tag::Rfc, Cldr don‘t have their own candidates, because it‘s meaningless to compare the extensions, privateuse, etc.

Set the script (with capitalize)

Set the variants as an Array.

[Validate]