From da5703df98ac2e56d1696749e43a2126cbb60b2b Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sun, 1 Dec 2024 21:57:26 -0600 Subject: [PATCH] support per-language fonts (for Japanese etc) --- index.html | 4 ++-- js/localization.js | 12 ++++++++++++ locale/en/messages.json | 3 +++ locale/uk/messages.json | 3 +++ src/css/main.css | 6 +++++- src/css/tabs/motors.css | 14 -------------- tabs/mixer.js | 5 +++-- tabs/outputs.html | 6 +----- tabs/outputs.js | 33 --------------------------------- 9 files changed, 29 insertions(+), 57 deletions(-) diff --git a/index.html b/index.html index 6a5cfddce..6201bb006 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + @@ -384,4 +384,4 @@

- \ No newline at end of file + diff --git a/js/localization.js b/js/localization.js index 2c7e49cd6..6da7a92ad 100644 --- a/js/localization.js +++ b/js/localization.js @@ -173,6 +173,11 @@ i18n.localize = function (reTranslate = false) { const element = $(this); element.attr('placeholder', translate(element.attr('i18n_placeholder'))); }); + + $('[i18n_lang]').each(function() { + const element = $(this); + element.attr('lang', translate(element.attr('i18n_lang'))); + }); } else { $('[i18n]:not(.i18n-replaced)').each(function() { @@ -234,6 +239,13 @@ i18n.localize = function (reTranslate = false) { element.attr('placeholder', translate(element.attr('i18n_placeholder'))); element.addClass('i18n_placeholder-replaced'); }); + + $('[i18n_lang]:not(.i18n_lang-replaced)').each(function() { + const element = $(this); + element.attr('lang', translate(element.attr('i18n_lang'))); + element.addClass('i18n_lang-replaced'); + }); + } return localized; diff --git a/locale/en/messages.json b/locale/en/messages.json index e0d9c2847..afef64449 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -6152,5 +6152,8 @@ }, "adsbHeartbeatTotalMessages": { "message": "Heartbeat msgs" + }, + "currentLanguage": { + "message": "en" } } diff --git a/locale/uk/messages.json b/locale/uk/messages.json index 74b236e97..bb0ab4a84 100644 --- a/locale/uk/messages.json +++ b/locale/uk/messages.json @@ -5926,5 +5926,8 @@ }, "adsbHeartbeatTotalMessages": { "message": "Повід. сигналів перевірки" + }, + "currentLanguage": { + "message": "uk" } } diff --git a/src/css/main.css b/src/css/main.css index 6a011d8eb..9dec4129e 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -2332,4 +2332,8 @@ ol li { .bold { font-weight: bold; -} \ No newline at end of file +} + +*:lang(ja) { + font-family:"ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro",Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif; +} diff --git a/src/css/tabs/motors.css b/src/css/tabs/motors.css index 3802d31c1..046fc078a 100644 --- a/src/css/tabs/motors.css +++ b/src/css/tabs/motors.css @@ -464,17 +464,3 @@ .tab-motors .config-section .number input { margin-right: 4px; } - -.tab-motors .mixerPreview { - position: relative; -} - -.tab-motors .motorNumber { - position: absolute; - font-size: 1.4em; - visibility: hidden; -} - -.tab-motors .mixer-preview-image-numbers { - width: fit-content; -} diff --git a/tabs/mixer.js b/tabs/mixer.js index e40fb07c6..be93c3026 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -476,7 +476,6 @@ TABS.mixer.initialize = function (callback, scrollPosition) { $("#motorNumber"+index).css("left", left_px + "px"); $("#motorNumber"+index).css("top", top_px + "px"); $("#motorNumber"+index).removeClass("is-hidden"); - $("#motorNumber"+index).css("visibility", "visible"); } } } @@ -545,7 +544,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { } } - labelMotorNumbers(); + labelMotorNumbers(); i18n.localize();; } @@ -611,6 +610,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { } } + return (errorCount == 0); } @@ -661,6 +661,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { const path = './resources/motor_order/' + currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg'; $('.mixerPreview img').attr('src', path); + renderServoOutputImage(); }; diff --git a/tabs/outputs.html b/tabs/outputs.html index 64a714762..d57cc76d6 100644 --- a/tabs/outputs.html +++ b/tabs/outputs.html @@ -117,11 +117,7 @@
- -
1
-
2
-
3
-
4
+
diff --git a/tabs/outputs.js b/tabs/outputs.js index 68b95811f..d936d18af 100644 --- a/tabs/outputs.js +++ b/tabs/outputs.js @@ -257,7 +257,6 @@ TABS.outputs.initialize = function (callback) { const path = './resources/motor_order/' + mixer.getById(val).image + (isReversed ? "_reverse" : "") + '.svg'; $('.mixerPreview img').attr('src', path); - labelMotorNumbers(); } function process_servos() { @@ -718,38 +717,6 @@ TABS.outputs.initialize = function (callback) { GUI.content_ready(callback); } - function labelMotorNumbers() { - - if (mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).image != 'quad_x') { - return; - } - - - let index = 0; - var rules = FC.MOTOR_RULES.get(); - - for (const i in rules) { - if (rules.hasOwnProperty(i)) { - const rule = rules[i]; - index++; - - let top_px = 30; - let left_px = 28; - if (rule.getRoll() < -0.5) { - left_px = $("#motor-mixer-preview-img").width() - 20; - } - - if (rule.getPitch() > 0.5) { - top_px = $("#motor-mixer-preview-img").height() - 20; - } - $("#motorNumber"+index).css("left", left_px + "px"); - $("#motorNumber"+index).css("top", top_px + "px"); - $("#motorNumber"+index).css("visibility", "visible"); - } - } - } - - }; TABS.outputs.cleanup = function (callback) {