Module: ImmosquareConstants::Locale

Defined in:
lib/immosquare-constants/locale.rb

Constant Summary collapse

LOCALES =
{
  # Afrikaans (South Africa, Namibia)
  :af      => "Afrikaans",
  # Amharic (Ethiopia)
  :am      => "አማርኛ",
  # Arabic (Middle East, North Africa)
  :ar      => "العربية",
  # Azerbaijani (Azerbaijan)
  :az      => "Azərbaycan",
  # Belarusian (Belarus)
  :be      => "Беларуская",
  # Bulgarian (Bulgaria)
  :bg      => "Български",
  # Bengali (Bangladesh, India)
  :bn      => "বাংলা",
  # Bosnian (Bosnia and Herzegovina)
  :bs      => "Bosanski",
  # Catalan (Spain - Catalonia, Andorra)
  :ca      => "Català",
  # Czech (Czech Republic)
  :cs      => "Čeština",
  # Welsh (United Kingdom - Wales)
  :cy      => "Cymraeg",
  # Danish (Denmark, Greenland, Faroe Islands)
  :da      => "Dansk",
  # German (Germany, Austria, Switzerland, Liechtenstein, Luxembourg)
  :de      => "Deutsch",
  :"de-AT" => "Deutsch (Österreich)",
  :"de-CH" => "Deutsch (Schweiz)",
  :"de-DE" => "Deutsch (Deutschland)",
  # Greek (Greece, Cyprus)
  :el      => "Ελληνικά",
  # English (United Kingdom, United States, Australia, Canada, and many others)
  :en      => "English",
  :"en-AU" => "English (Australia)",
  :"en-CA" => "English (Canada)",
  :"en-GB" => "English (United Kingdom)",
  :"en-IE" => "English (Ireland)",
  :"en-IN" => "English (India)",
  :"en-NZ" => "English (New Zealand)",
  :"en-US" => "English (United States)",
  :"en-ZA" => "English (South Africa)",
  # Spanish (Spain, Latin America, United States)
  :es      => "Español",
  :"es-LA" => "Español (Latinoamérica)",
  :"es-AR" => "Español (Argentina)",
  :"es-BO" => "Español (Bolivia)",
  :"es-CL" => "Español (Chile)",
  :"es-CO" => "Español (Colombia)",
  :"es-CR" => "Español (Costa Rica)",
  :"es-DO" => "Español (República Dominicana)",
  :"es-EC" => "Español (Ecuador)",
  :"es-GT" => "Español (Guatemala)",
  :"es-HN" => "Español (Honduras)",
  :"es-MX" => "Español (México)",
  :"es-NI" => "Español (Nicaragua)",
  :"es-PA" => "Español (Panamá)",
  :"es-PE" => "Español (Perú)",
  :"es-PR" => "Español (Puerto Rico)",
  :"es-PY" => "Español (Paraguay)",
  :"es-SV" => "Español (El Salvador)",
  :"es-US" => "Español (Estados Unidos)",
  :"es-UY" => "Español (Uruguay)",
  :"es-VE" => "Español (Venezuela)",
  # Estonian (Estonia)
  :et      => "Eesti",
  # Persian (Iran, Afghanistan, Tajikistan)
  :fa      => "فارسی",
  # Finnish (Finland)
  :fi      => "Suomi",
  # French (France, Canada, Belgium, Switzerland, Luxembourg, and others)
  :fr      => "Français",
  :"fr-BE" => "Français (Belgique)",
  :"fr-CA" => "Français (Canada)",
  :"fr-CH" => "Français (Suisse)",
  :"fr-LU" => "Français (Luxembourg)",
  # Gujarati (India)
  :gu      => "ગુજરાતી",
  # Hebrew (Israel)
  :he      => "עברית",
  # Hindi (India)
  :hi      => "हिन्दी",
  # Croatian (Croatia, Bosnia and Herzegovina)
  :hr      => "Hrvatski",
  # Hungarian (Hungary)
  :hu      => "Magyar",
  # Armenian (Armenia)
  :hy      => "Հայերեն",
  # Indonesian (Indonesia)
  :id      => "Bahasa Indonesia",
  # Icelandic (Iceland)
  :is      => "Íslenska",
  # Italian (Italy, Switzerland)
  :it      => "Italiano",
  :"it-CH" => "Italiano (Svizzera)",
  # Japanese (Japan)
  :ja      => "日本語",
  # Georgian (Georgia)
  :ka      => "ქართული",
  # Kazakh (Kazakhstan)
  :kk      => "Қазақ",
  # Khmer (Cambodia)
  :km      => "ភាសាខ្មែរ",
  # Kannada (India)
  :kn      => "ಕನ್ನಡ",
  # Korean (South Korea, North Korea)
  :ko      => "한국어",
  # Kyrgyz (Kyrgyzstan)
  :ky      => "Кыргызча",
  # Lao (Laos)
  :lo      => "ລາວ",
  # Lithuanian (Lithuania)
  :lt      => "Lietuvių",
  # Latvian (Latvia)
  :lv      => "Latviešu",
  # Macedonian (North Macedonia)
  :mk      => "Македонски",
  # Malayalam (India)
  :ml      => "മലയാളം",
  # Mongolian (Mongolia)
  :mn      => "Монгол",
  # Marathi (India)
  :mr      => "मराठी",
  # Malay (Malaysia, Brunei)
  :ms      => "Bahasa Melayu",
  # Maltese (Malta)
  :mt      => "Malti",
  # Burmese (Myanmar)
  :my      => "မြန်မာ",
  # Nepali (Nepal)
  :ne      => "नेपाली",
  # Dutch (Netherlands, Belgium)
  :nl      => "Nederlands",
  # Norwegian (Norway)
  :no      => "Norsk",
  # Odia (India)
  :or      => "ଓଡ଼ିଆ",
  # Punjabi (India, Pakistan)
  :pa      => "ਪੰਜਾਬੀ",
  # Polish (Poland)
  :pl      => "Polski",
  # Pashto (Afghanistan, Pakistan)
  :ps      => "پښتو",
  # Portuguese (Portugal, Brazil, and others)
  :pt      => "Português",
  :"pt-BR" => "Português (Brasil)",
  # Romanian (Romania, Moldova)
  :ro      => "Română",
  # Russian (Russia, Belarus, and others)
  :ru      => "Русский",
  # Sindhi (Pakistan, India)
  :sd      => "سنڌي",
  # Sinhala (Sri Lanka)
  :si      => "සිංහල",
  # Slovak (Slovakia)
  :sk      => "Slovenčina",
  # Slovenian (Slovenia)
  :sl      => "Slovenščina",
  # Somali (Somalia, Kenya)
  :so      => "Soomaali",
  # Albanian (Albania, Kosovo)
  :sq      => "Shqip",
  # Serbian (Serbia, Bosnia and Herzegovina, Montenegro)
  :sr      => "Српски",
  # Swedish (Sweden, Finland)
  :sv      => "Svenska",
  # Swahili (Kenya, Tanzania, Uganda, and others)
  :sw      => "Kiswahili",
  # Tamil (India, Sri Lanka)
  :ta      => "தமிழ்",
  # Telugu (India)
  :te      => "తెలుగు",
  # Tajik (Tajikistan)
  :tg      => "Тоҷикӣ",
  # Thai (Thailand)
  :th      => "ไทย",
  # Tagalog (Philippines)
  :tl      => "Filipino",
  # Turkish (Turkey, Cyprus)
  :tr      => "Türkçe",
  # Ukrainian (Ukraine)
  :uk      => "Українська",
  # Urdu (Pakistan, India)
  :ur      => "اردو",
  # Uzbek (Uzbekistan)
  :uz      => "O'zbek",
  # Vietnamese (Vietnam)
  :vi      => "Tiếng Việt",
  # Xhosa (South Africa)
  :xh      => "isiXhosa",
  # Chinese (China, Taiwan, Singapore, Hong Kong)
  :zh      => "中文",
  :"zh-CN" => "中文 (简体)",
  :"zh-TW" => "中文 (繁體)",
  # Zulu (South Africa)
  :zu      => "isiZulu"
}.freeze

Class Method Summary collapse

Class Method Details

.languages_with_native_namesObject

##

Renvoie la liste des langues disponibles sans les langues régionales.

##


206
207
208
# File 'lib/immosquare-constants/locale.rb', line 206

def languages_with_native_names
  LOCALES.reject {|key, _value| key.to_s.include?("-") }
end

.native_name_for_locale(locale) ⇒ Object

##

Renvoie le nom de la langue correspondant à la locale passée en paramètre.

##


213
214
215
216
217
218
219
220
221
# File 'lib/immosquare-constants/locale.rb', line 213

def native_name_for_locale(locale)
  begin
    return nil if locale.nil? || locale.to_s.strip.empty?
    key = locale.to_s.split("-").map.with_index {|part, index| index == 0 ? part.downcase : part.upcase }.join("-").to_sym
    LOCALES[key]
  rescue StandardError
    nil
  end
end