Merge pull request #2436 from crazyserver/MOBILE-3456

MOBILE-3456 lang: Check parent lang from langname
main
Juan Leyva 2020-07-02 12:44:59 +02:00 committed by GitHub
commit c8c51a65cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 21 additions and 28 deletions

View File

@ -120,8 +120,6 @@ function add_langs_to_config($langs, $config) {
function get_langfolder($lang) {
$folder = LANGPACKSFOLDER.'/'.str_replace('-', '_', $lang);
if (!is_dir($folder) || !is_file($folder.'/langconfig.php')) {
echo "Cannot translate $folder, folder not found";
return false;
}
@ -173,6 +171,8 @@ function reset_translations_strings() {
function build_lang($lang, $keys) {
$langfoldername = get_langfolder($lang);
if (!$langfoldername) {
echo "Cannot translate $lang, folder not found";
return false;
}
@ -185,12 +185,15 @@ function build_lang($lang, $keys) {
$total = count($keys);
$local = 0;
$string = get_translation_strings($langfoldername, 'langconfig');
$parent = isset($string['parentlanguage']) ? $string['parentlanguage'] : "";
$langparts = explode('-', $lang, 2);
$parentname = $langparts[0] ?? "";
$parent = "";
echo "Processing $lang";
if ($parent != "" && $parent != $lang) {
echo " ($parent)";
// Check parent language exists.
if ($parentname != $lang && get_langfolder($parentname)) {
echo " ($parentname)";
$parent = $parentname;
}
$langFile = false;
@ -247,6 +250,12 @@ function build_lang($lang, $keys) {
$translations[$key] = html_entity_decode($text);
}
if (!empty($parent)) {
$translations['core.parentlanguage'] = $parent;
} else if (isset($translations['core.parentlanguage'])) {
unset($translations['core.parentlanguage']);
}
// Sort and save.
ksort($translations);
file_put_contents(ASSETSPATH.$lang.'.json', str_replace('\/', '/', json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)));
@ -275,6 +284,8 @@ function progressbar($percentage) {
function detect_lang($lang, $keys) {
$langfoldername = get_langfolder($lang);
if (!$langfoldername) {
echo "Cannot translate $lang, folder not found";
return false;
}

View File

@ -1913,7 +1913,6 @@
"core.openmodinbrowser": "Obre {{$a}} al navegador",
"core.othergroups": "Altres grups",
"core.pagea": "Pàgina {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Utilitzeu el botó de baix per pagar i inscriure-us.",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telèfon",

View File

@ -1909,7 +1909,6 @@
"core.openmodinbrowser": "Otevřít {{$a}} v prohlížeči",
"core.othergroups": "Další skupiny",
"core.pagea": "Stránka {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Pomocí tlačítka níže můžete provést platbu a během několika minut se zapsat do kurzu!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefon",

View File

@ -1752,7 +1752,6 @@
"core.openinbrowser": "Åben i browser",
"core.othergroups": "Andre grupper",
"core.pagea": "Side {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Brug knappen forneden til at betale og blive tilmeldt umiddelbart derefter.",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefon",

View File

@ -1841,7 +1841,6 @@
"core.openinbrowser": "Ανοίξτε στον περιηγητή.",
"core.othergroups": "Άλλες ομάδες",
"core.pagea": "Σελίδα {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Χρησιμοποιήστε το παρακάτω πλήκτρο για να πληρώσετε και να εγγραφείτε μέσα σε λίγα λεπτά!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Τηλέφωνο",

View File

@ -14,6 +14,7 @@
"core.listsep": ",",
"core.login.loginsteps": "For full access to this site, you first need to create an account.",
"core.notenrolledprofile": "This profile is not available because this user is not enrolled in this course.",
"core.parentlanguage": "en",
"core.paymentinstant": "Use the button below to pay and be enrolled within minutes!",
"core.settings.license": "License",
"core.strftimedate": "%B %d, %Y",

View File

@ -1913,7 +1913,6 @@
"core.openmodinbrowser": "Open {{$a}} in browser",
"core.othergroups": "Other groups",
"core.pagea": "Page {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Use the button below to pay and be enrolled within minutes!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Phone",

View File

@ -1913,7 +1913,7 @@
"core.openmodinbrowser": "Abrir {{$a}} en navegador",
"core.othergroups": "Otros grupos",
"core.pagea": "Página {{$a}}",
"core.parentlanguage": "",
"core.parentlanguage": "es",
"core.paymentinstant": "¡Utilice el botón de abajo para pagar y poder inscribirse en minutos!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Teléfono",

View File

@ -1913,7 +1913,6 @@
"core.openmodinbrowser": "Abrir {{$a}} en el navegador",
"core.othergroups": "Otros grupos",
"core.pagea": "Página {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "¡Utilice el botón de abajo para pagar y poder matricularse en minutos!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Teléfono",

View File

@ -1875,7 +1875,6 @@
"core.openinbrowser": "Ouvrir dans le navigateur",
"core.othergroups": "Autres groupes",
"core.pagea": "Page {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Le bouton ci-dessous vous permet de payer et de vous inscrire en quelques minutes !",
"core.percentagenumber": "{{$a}} %",
"core.phone": "Téléphone",

View File

@ -1521,7 +1521,6 @@
"core.online": "Online",
"core.othergroups": "Egyéb csoportok",
"core.pagea": "{{$a}} oldal",
"core.parentlanguage": "",
"core.paymentinstant": "A fizetéshez és a perceken belüli beiratkozáshoz használja az alábbi gombot!",
"core.phone": "Telefon",
"core.pictureof": "Kép",

View File

@ -1769,7 +1769,6 @@
"core.openinbrowser": "Apri nel browser",
"core.othergroups": "Altri gruppi",
"core.pagea": "Pagina {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Utilizza il pulsante sottostante per pagare ed essere iscritto in pochi minuti!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefono",

View File

@ -1717,7 +1717,6 @@
"core.openinbrowser": "ブラウザで開く",
"core.othergroups": "他のグループ",
"core.pagea": "ページ {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "下のボタンをお使いください。支払いおよび登録がすぐに完了します!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "電話",

View File

@ -1385,7 +1385,6 @@
"core.openfullimage": "전체 크기 이미지를 보려면 여기를 클릭하십시오.",
"core.openinbrowser": "브라우저에서 열기",
"core.pagea": "페이지 {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "신속하게 등록금 지불 및 등록을 마치려면 아래의 버튼을 사용하시오!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "전화",

View File

@ -1634,7 +1634,6 @@
"core.openinbrowser": "Atidaryti naršyklėje",
"core.othergroups": "Kitos grupės",
"core.pagea": "{{$a}} puslapis",
"core.parentlanguage": "",
"core.paymentinstant": "Naudokite toliau pateiktą mygtuką, kad sumokėtumėte ir būtumėte įregistruoti per kelias minutes.",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefonas",

View File

@ -1576,7 +1576,6 @@
"core.online": "På nett",
"core.othergroups": "Andre grupper",
"core.pagea": "Side {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Bruk knappen under for å betale og melde deg på kurset.",
"core.phone": "Telefon",
"core.pictureof": "Bilde av {{$a}}",

View File

@ -1809,7 +1809,7 @@
"core.openinbrowser": "Abrir no navegador",
"core.othergroups": "Outros grupos",
"core.pagea": "Página {{$a}}",
"core.parentlanguage": "",
"core.parentlanguage": "pt",
"core.paymentinstant": "Clique o botão abaixo para efetuar o pagamento e fazer a sua inscrição em poucos minutos!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Fone",

View File

@ -1913,7 +1913,6 @@
"core.openmodinbrowser": "Abrir {{$a}} no navegador",
"core.othergroups": "Outros grupos",
"core.pagea": "Página {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Use o botão abaixo para pagar e completar a inscrição!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefone",

View File

@ -1841,7 +1841,6 @@
"core.openinbrowser": "Odpri v brskalniku",
"core.othergroups": "Ostale skupine",
"core.pagea": "Stran {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "Uporabite spodnje gumbe za plačilo in vpis v nekaj minutah!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefon",

View File

@ -1700,7 +1700,6 @@
"core.openinbrowser": "Отвори у веб читачу",
"core.othergroups": "Друге групе",
"core.pagea": "Страница {{$a}}",
"core.parentlanguage": "en",
"core.paymentinstant": "Употребите дугме испод како бисте извршили уплату и уписали курс у року од неколико минута!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Телефон",

View File

@ -1700,7 +1700,6 @@
"core.openinbrowser": "Otvori u veb čitaču",
"core.othergroups": "Druge grupe",
"core.pagea": "Stranica {{$a}}",
"core.parentlanguage": "en",
"core.paymentinstant": "Upotrebite dugme ispod kako biste izvršili uplatu i upisali kurs u roku od nekoliko minuta!",
"core.percentagenumber": "{{$a}}%",
"core.phone": "Telefon",

View File

@ -1844,7 +1844,6 @@
"core.openinbrowser": "在浏览器中打开",
"core.othergroups": "其他小组",
"core.pagea": "页 {{$a}}",
"core.parentlanguage": "",
"core.paymentinstant": "点击下面的按钮便可以快速付费并加入课程!",
"core.phone": "电话",
"core.pictureof": "{{$a}}的头像",

View File

@ -1636,7 +1636,6 @@
"core.openinbrowser": "以瀏覽器開啟",
"core.othergroups": "其他群組",
"core.pagea": "第 {{$a}} 頁",
"core.parentlanguage": "",
"core.paymentinstant": "使用以下按鈕立即付款及註冊。",
"core.percentagenumber": "{{$a}}%",
"core.phone": "電話",