Class | Locale::Tag::Common
In: | lib/locale/tag/common.rb
Parent: | Locale::Tag::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=

### Included Modules

Util::Memoizable

### 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

new(language, script = nil, region = nil, variants = [])

Create a Locale::Tag::Common.

parse(tag)

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

### Public Instance methods

candidates()

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.

script=(val)

Set the script (with capitalize)

variants=(val)

Set the variants as an Array.

[Validate]