Last active
September 18, 2022 02:39
-
-
Save pjaudiomv/fb9da334074eaa2cd4485bae76d839c2 to your computer and use it in GitHub Desktop.
Get BMLT Server Langs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ret = null; | |
$uri = 'https://latest.aws.bmlt.app/main_server/client_interface/json/?switcher=GetServerInfo'; | |
$data = file_get_contents($uri); | |
if ($data) { | |
$ret = array(); | |
$data = json_decode($data, true); | |
$langs = explode(",", $data[0]["langs"]); | |
sort($langs); | |
$default_lang = $data[0]["nativeLang"]; | |
$c = 0; | |
foreach ($langs as $lang) { | |
# Danish is set to country not language code, so we must account for this. | |
$langName = $lang == 'dk' ? 'da' : $lang; | |
$langName = Locale::getDisplayLanguage($langName, $langName); | |
$langName = mb_str_split($langName); | |
$langName = mb_strtoupper($langName[0]) . implode('', array_slice($langName, 1)); | |
$ret['languages'][$c]['key'] = $lang; | |
$ret['languages'][$c]['name'] = $langName; | |
if ($lang === $default_lang) { | |
$ret['languages'][$c]['default'] = true; | |
} | |
$c++; | |
} | |
} | |
echo json_encode($ret); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment