PHP Classes


Recommend this page to a friend!
  Classes of Peter Kahl  >  PHP Language Info  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Language Info
Get information about a language
Author: By
Last change: Update of
Date: 2 years ago
Size: 2,535 bytes


Class file image Download

Language Info (Multilingual)

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:

<pre> 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 </pre>

How to Use

use peterkahl\LanguageInfo\LanguageInfo;

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


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
For more information send a message to info at phpclasses dot org.