From aca3bc870b534f64b0ee39606a4b57db0405367b Mon Sep 17 00:00:00 2001 From: dualshock-tools Date: Sun, 17 Nov 2024 17:27:20 +0100 Subject: [PATCH] Add support for RTL languages and ar_ar translation --- core.js | 61 ++++++++++----- index.html | 5 +- lang/ar_ar.json | 192 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 21 deletions(-) create mode 100644 lang/ar_ar.json diff --git a/core.js b/core.js index 1a51315..f79e481 100644 --- a/core.js +++ b/core.js @@ -12,27 +12,29 @@ var has_changes_to_write = 0; var lang_orig_text = {}; var lang_cur = {}; var lang_disabled = true; +var lang_cur_direction = "ltr"; var gj = 0; var gu = 0; // Alphabetical order var available_langs = { - "bg_bg": { "name": "Български", "file": "bg_bg.json"}, - "cz_cz": { "name": "Čeština", "file": "cz_cz.json"}, - "de_de": { "name": "Deutsch", "file": "de_de.json"}, - "es_es": { "name": "Español", "file": "es_es.json"}, - "fr_fr": { "name": "Français", "file": "fr_fr.json"}, - "hu_hu": { "name": "Magyar", "file": "hu_hu.json"}, - "it_it": { "name": "Italiano", "file": "it_it.json"}, - "jp_jp": { "name": "日本語", "file": "jp_jp.json"}, - "ko_kr": { "name": "한국어", "file": "ko_kr.json"}, - "nl_nl": { "name": "Nederlands", "file": "nl_nl.json"}, - "pl_pl": { "name": "Polski", "file": "pl_pl.json"}, - "pt_br": { "name": "Português do Brasil", "file": "pt_br.json"}, - "ru_ru": { "name": "Русский", "file": "ru_ru.json"}, - "tr_tr": { "name": "Türkçe", "file": "tr_tr.json"}, - "zh_cn": { "name": "中文", "file": "zh_cn.json"}, - "zh_tw": { "name": "中文(繁)", "file": "zh_tw.json"} + "ar_ar": { "name": "العربية", "file": "ar_ar.json", "direction": "rtl"}, + "bg_bg": { "name": "Български", "file": "bg_bg.json", "direction": "ltr"}, + "cz_cz": { "name": "Čeština", "file": "cz_cz.json", "direction": "ltr"}, + "de_de": { "name": "Deutsch", "file": "de_de.json", "direction": "ltr"}, + "es_es": { "name": "Español", "file": "es_es.json", "direction": "ltr"}, + "fr_fr": { "name": "Français", "file": "fr_fr.json", "direction": "ltr"}, + "hu_hu": { "name": "Magyar", "file": "hu_hu.json", "direction": "ltr"}, + "it_it": { "name": "Italiano", "file": "it_it.json", "direction": "ltr"}, + "jp_jp": { "name": "日本語", "file": "jp_jp.json", "direction": "ltr"}, + "ko_kr": { "name": "한국어", "file": "ko_kr.json", "direction": "ltr"}, + "nl_nl": { "name": "Nederlands", "file": "nl_nl.json", "direction": "ltr"}, + "pl_pl": { "name": "Polski", "file": "pl_pl.json", "direction": "ltr"}, + "pt_br": { "name": "Português do Brasil", "file": "pt_br.json", "direction": "ltr"}, + "ru_ru": { "name": "Русский", "file": "ru_ru.json", "direction": "ltr"}, + "tr_tr": { "name": "Türkçe", "file": "tr_tr.json", "direction": "ltr"}, + "zh_cn": { "name": "中文", "file": "zh_cn.json", "direction": "ltr"}, + "zh_tw": { "name": "中文(繁)", "file": "zh_tw.json", "direction": "ltr"} }; function buf2hex(buffer) { @@ -1738,7 +1740,7 @@ function lang_init() { var ljson = available_langs[nlang]; if(ljson !== undefined) { la("lang_init", {"l": nlang}); - lang_translate(ljson["file"], nlang); + lang_translate(ljson["file"], nlang, ljson["direction"]); } } @@ -1761,7 +1763,8 @@ function lang_set(l, skip_modal=false) { lang_reset_page(); } else { var file = available_langs[l]["file"]; - lang_translate(file, l); + var direction = available_langs[l]["direction"]; + lang_translate(file, l, direction); } createCookie("force_lang", l); @@ -1772,6 +1775,7 @@ function lang_set(l, skip_modal=false) { } function lang_reset_page() { + lang_set_direction("ltr", "en_us"); var items = document.getElementsByClassName('ds-i18n'); for(i=0; i DualShock Calibration GUI - @@ -20,6 +20,7 @@ integrity="sha384-h/hnnw1Bi4nbpD6kE7nYfCXzovi622sY5WBxww8ARKwpdLj5kUWjRuyiXaD1U2JT" crossorigin="anonymous"> + @@ -606,7 +607,7 @@