PHP code example of petercoles / multilingual-language-list
1. Go to this page and download the library: Download petercoles/multilingual-language-list library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
petercoles / multilingual-language-list example snippets
'providers' => [
// ...
PeterColes\Languages\LanguagesServiceProvider::class,
// ...
],
'Languages' => PeterColes\Languages\LanguagesFacade::class,
Languages::lookup();
// returns
{
"ab": "Abkhazian",
...
"zu": "Zulu"
}
Languages::lookup(['en', 'fr', 'de']);
// returns
{
"en": "English",
"fr": "French",
"de": "German"
}
Languages::lookup(['en', 'fr', 'de'], 'fr');
// returns
{
"de": "allemand",
"en": "anglais",
"fr": "français"
}
Languages::lookup(['en', 'fr', 'de'], 'fr', true);
// returns
{
"allemand": "de",
"anglais": "en",
"français": "fr"
}
Languages::lookup(['en', 'fr', 'de', 'bs'], 'bs_Cyrl');
// returns
{
"bs": "босански",
"en": "енглески",
"de": "немачки",
"fr": "француски"
}
Languages::keyValue();
// returns
[
{"key": "ab", "value": "Abkhazian"},
{"key": "aa", "value": "Afar"},
...
{"key": "za", "value": "Zhuang"},
{"key": "zu", "value": "Zulu"}
]
Languages::keyValue('minor');
// returns
[
{"key": "ab", "value": "Abkhazian"},
{"key": "ace", "value": "Achinese"},
{"key": "ach", "value": "Acoli"},
...
{"key": "gbz", "value": "Zoroastrian Dari"},
{"key": "zu", "value": "Zulu"},
{"key": "zun", "value": "Zuni"}
]
Languages::keyValue(['en', 'ja', 'zh'], 'zh', 'label', 'text');
// returns
[
{"label": "ja", "text": "日文"},
{"label": "en", "text": "英文"},
{"label": "zh", "text": "中文"}
]
Languages::lookup(['en', 'fr', 'de', 'ja', 'ru', 'zh'], 'mixed');
// returns
{
"en": "English",
"fr": "français",
"de": "Deutsch",
"ja": "日本語",
"ru": "русский",
"zh": "中文",
}
Languages::keyValue(['en', 'fr', 'de', 'ja', 'ru', 'zh'], 'mixed');
// returns
[
{"key" => "en", "value" => "English"},
{"key" => "fr", "value" => "français"},
{"key" => "de", "value" => "Deutsch"},
{"key" => "ja", "value" => "日本語"},
{"key" => "ru", "value" => "русский"},
{"key" => "zh", "value" => "中文"}
]
$languageKeys = Languages::lookup('major')->keys()->toArray();
// returns
['ab', ... 'zu']
$mixedLanguages = Languages::lookup($languageKeys, 'mixed');
// returns
{
"af": "Afrikaans",
"ak": "Akan",
"sq": "shqip",
"am": "አማርኛ",
"ar": "العربية",
"hy": "հայերեն",
"as": "অসমীয়া",
...
"zu": "isiZulu"
}
Languages::lookup($mixedLanguages->keys()->toArray(), 'fr');