peterkahl/language-info-multilingual

Converts language code to a full name in requested language.

v8.0.1 2018-03-22 14:51 UTC

README

Converts language code to a full name in requested language.

Translations are available in these languages:

  • Arabic (عربى)
  • Czech (čeština)
  • German (Deutsch)
  • Danish (dansk)
  • English
  • Spanish (español)
  • French (français)
  • Hebrew (עִברִית)
  • Italian (italiano)
  • Japanese (日本語)
  • Dutch (Nederlands)
  • Portuguese (português)
  • Russian (русский)
  • Slovak (slovenčina)
  • Chinese simplified (中文简体)
  • Chinese traditional (中文繁體)

Language codes that can be converted to full name in any of the above languages:

albanian
arabic
armenian
azeri
bengali
bulgarian
burmese
cebuano
chinese
chinese simplified
chinese traditional
croatian
czech
danish
dutch
english
english gb
english us
estonian
farsi
finnish
french
georgian
german
greek
gujarati
hausa
hawaiian
hebrew
hindi
hungarian
icelandic
indonesian
italian
japanese
kazakh
khmer
korean
kyrgyz
lao
latin
latvian
lithuanian
macedonian
malayalam
mongolian
nepali
norwegian
pashto
pidgin
polish
portuguese
romanian
russian
serbian
sinhalese
slovak
slovene
somali
spanish
swahili
swedish
tagalog
tamil
thai
tibetan
turkish
ukrainian
urdu
uzbek
vietnamese
welsh

How to Use

use peterkahl\LanguageInfo\LanguageInfo;

echo LanguageInfo::getName($key, $langCode);

Parameters

key ... The word (language name or code) we want to translate. Admissible values are 2-letter code, 3-letter code or full name in English (case-insensitive).

langCode ... The code of the language we want to translate the key to. Admissible values are 2-letter code (case-insensitive).

Usage Examples

use peterkahl\LanguageInfo\LanguageInfo;

echo LanguageInfo::getName('AR', 'EN');       # Arabic

echo LanguageInfo::getName('ara', 'EN');      # Arabic

echo LanguageInfo::getName('HE', 'ar');       # اللغة العبرية

echo LanguageInfo::getName('ru_RU', 'de_AT'); # Russisch

echo LanguageInfo::getName('Russian', 'zh');  # 俄语

echo LanguageInfo::getName('bo', 'en-us');    # Tibetan

echo LanguageInfo::getName('bo', 'fr');       # tibétain

echo LanguageInfo::getName('bod', 'DE');      # Tibetisch

echo LanguageInfo::getName('zh-cn', 'en');    # Chinese simplified

echo LanguageInfo::getName('zh-tw', 'en');    # Chinese traditional

echo LanguageInfo::getName('chinese traditional', 'de'); # Chinesisch traditionell

echo LanguageInfo::getName('zh', 'en');       # Chinese

# Non-existent code
echo LanguageInfo::getName('xx-xx', 'en');    # unknown xx-xx