Module: Locale::Info

Defined in:
lib/locale/info/region.rb,
lib/locale/info/language.rb

Defined Under Namespace

Classes: Language, Region

Constant Summary collapse

@@regions =
Hash.new
@@lang_two_codes =
Hash.new
@@lang_three_codes =
Hash.new

Class Method Summary collapse

Class Method Details

.get_language(code) ⇒ Object

Returns the language for the given 2 or 3 digit code.

Need to require ‘locale/info’ or ‘locale/language’.



123
124
125
# File 'lib/locale/info/language.rb', line 123

def get_language(code)
  @@lang_three_codes[code] || @@lang_two_codes[code]
end

.get_region(code) ⇒ Object

Returns the region for the given code.

You need to require ‘locale/info’ or ‘locale/info/region’.



63
64
65
# File 'lib/locale/info/region.rb', line 63

def get_region(code)
  @@regions[code]
end

.language_code?(code) ⇒ Boolean

Returns the language code is valid.

Need to require ‘locale/info’ or ‘locale/language’.

Returns:

  • (Boolean)


130
131
132
# File 'lib/locale/info/language.rb', line 130

def language_code?(code)
  get_language(code) != nil
end

.regionsObject

Returns a hash of all the ISO regions. The hash is Region where the string is the 2 digit region code from the ISO 3166 data.

You need to require ‘locale/info’ or ‘locale/region’.



56
57
58
# File 'lib/locale/info/region.rb', line 56

def regions
  @@regions
end

.three_languagesObject

Returns a hash of all the ISO languages. The hash is language where the string is the 3 digit language code from the ISO 639 data. This contains all of the data from the ISO 639-3 data (7600 Languages).

Need to require ‘locale/info’ or ‘locale/language’.



107
108
109
# File 'lib/locale/info/language.rb', line 107

def three_languages
  @@lang_three_codes
end

.two_languagesObject

Returns a hash of all the ISO languages. The hash is language where the string is the 2 digit language code from the ISO 639-1 data. This contains all of the data from the ISO 639-1 data (186 Languages).

Need to require ‘locale/info’ or ‘locale/language’.



116
117
118
# File 'lib/locale/info/language.rb', line 116

def two_languages
  @@lang_two_codes
end

.valid_region_code?(code) ⇒ Boolean

Returns the region code is valid.

You need to require ‘locale/info’ or ‘locale/info/region’.

Returns:

  • (Boolean)


70
71
72
# File 'lib/locale/info/region.rb', line 70

def valid_region_code?(code)
  @@regions[code] != nil
end