Skip to content

Commit 090dd06

Browse files
committed
support per-language fonts (for Japanese etc)
1 parent 87a3042 commit 090dd06

File tree

9 files changed

+29
-57
lines changed

9 files changed

+29
-57
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html i18n_lang="currentLanguage">
33

44
<head>
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

js/localization.js

+12
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ i18n.localize = function (reTranslate = false) {
173173
const element = $(this);
174174
element.attr('placeholder', translate(element.attr('i18n_placeholder')));
175175
});
176+
177+
$('[i18n_lang]').each(function() {
178+
const element = $(this);
179+
element.attr('lang', translate(element.attr('i18n_lang')));
180+
});
176181
} else {
177182

178183
$('[i18n]:not(.i18n-replaced)').each(function() {
@@ -234,6 +239,13 @@ i18n.localize = function (reTranslate = false) {
234239
element.attr('placeholder', translate(element.attr('i18n_placeholder')));
235240
element.addClass('i18n_placeholder-replaced');
236241
});
242+
243+
$('[i18n_lang]:not(.i18n_lang-replaced)').each(function() {
244+
const element = $(this);
245+
element.attr('lang', translate(element.attr('i18n_lang')));
246+
element.addClass('i18n_lang-replaced');
247+
});
248+
237249
}
238250

239251
return localized;

locale/en/messages.json

+3
Original file line numberDiff line numberDiff line change
@@ -6152,5 +6152,8 @@
61526152
},
61536153
"adsbHeartbeatTotalMessages": {
61546154
"message": "Heartbeat msgs"
6155+
},
6156+
"currentLanguage": {
6157+
"message": "en"
61556158
}
61566159
}

locale/uk/messages.json

+3
Original file line numberDiff line numberDiff line change
@@ -5926,5 +5926,8 @@
59265926
},
59275927
"adsbHeartbeatTotalMessages": {
59285928
"message": "Повід. сигналів перевірки"
5929+
},
5930+
"currentLanguage": {
5931+
"message": "uk"
59295932
}
59305933
}

src/css/main.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -2332,4 +2332,8 @@ ol li {
23322332

23332333
.bold {
23342334
font-weight: bold;
2335-
}
2335+
}
2336+
2337+
*:lang(ja) {
2338+
font-family:"ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro",Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
2339+
}

src/css/tabs/motors.css

+1-15
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,4 @@
463463

464464
.tab-motors .config-section .number input {
465465
margin-right: 4px;
466-
}
467-
468-
.tab-motors .mixerPreview {
469-
position: relative;
470-
}
471-
472-
.tab-motors .motorNumber {
473-
position: absolute;
474-
font-size: 1.4em;
475-
visibility: hidden;
476-
}
477-
478-
.tab-motors .mixer-preview-image-numbers {
479-
width: fit-content;
480-
}
466+
}

tabs/mixer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
476476
$("#motorNumber"+index).css("left", left_px + "px");
477477
$("#motorNumber"+index).css("top", top_px + "px");
478478
$("#motorNumber"+index).removeClass("is-hidden");
479-
$("#motorNumber"+index).css("visibility", "visible");
480479
}
481480
}
482481
}
@@ -545,7 +544,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
545544
}
546545

547546
}
548-
labelMotorNumbers();
547+
labelMotorNumbers();
549548
i18n.localize();;
550549
}
551550

@@ -611,6 +610,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
611610
}
612611

613612
}
613+
614614
return (errorCount == 0);
615615
}
616616

@@ -661,6 +661,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
661661
const path = './resources/motor_order/'
662662
+ currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg';
663663
$('.mixerPreview img').attr('src', path);
664+
664665
renderServoOutputImage();
665666
};
666667

tabs/outputs.html

+1-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@
117117
<div class="motors right">
118118
<div class="half">
119119
<div class="mixerPreview">
120-
<img src="./resources/motor_order/custom.svg" id="motor-mixer-preview-img" />
121-
<div class="motorNumber" id="motorNumber1">1</div>
122-
<div class="motorNumber" id="motorNumber2">2</div>
123-
<div class="motorNumber" id="motorNumber3">3</div>
124-
<div class="motorNumber" id="motorNumber4">4</div>
120+
<img src="./resources/motor_order/custom.svg" />
125121
</div>
126122
</div>
127123
<div class="half">

tabs/outputs.js

-33
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ TABS.outputs.initialize = function (callback) {
257257
const path = './resources/motor_order/'
258258
+ mixer.getById(val).image + (isReversed ? "_reverse" : "") + '.svg';
259259
$('.mixerPreview img').attr('src', path);
260-
labelMotorNumbers();
261260
}
262261

263262
function process_servos() {
@@ -718,38 +717,6 @@ TABS.outputs.initialize = function (callback) {
718717
GUI.content_ready(callback);
719718
}
720719

721-
function labelMotorNumbers() {
722-
723-
if (mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).image != 'quad_x') {
724-
return;
725-
}
726-
727-
728-
let index = 0;
729-
var rules = FC.MOTOR_RULES.get();
730-
731-
for (const i in rules) {
732-
if (rules.hasOwnProperty(i)) {
733-
const rule = rules[i];
734-
index++;
735-
736-
let top_px = 30;
737-
let left_px = 28;
738-
if (rule.getRoll() < -0.5) {
739-
left_px = $("#motor-mixer-preview-img").width() - 20;
740-
}
741-
742-
if (rule.getPitch() > 0.5) {
743-
top_px = $("#motor-mixer-preview-img").height() - 20;
744-
}
745-
$("#motorNumber"+index).css("left", left_px + "px");
746-
$("#motorNumber"+index).css("top", top_px + "px");
747-
$("#motorNumber"+index).css("visibility", "visible");
748-
}
749-
}
750-
}
751-
752-
753720
};
754721

755722
TABS.outputs.cleanup = function (callback) {

0 commit comments

Comments
 (0)