Skip to content

Commit 9a6cdbb

Browse files
HThurenchmelevskij
authored andcommitted
Sort and translate font name at OSD tab (betaflight#3621)
* Translate font name in OSD tab * minor changes * minor changes 2
1 parent c4a4e2d commit 9a6cdbb

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

locales/en/messages.json

+42-2
Original file line numberDiff line numberDiff line change
@@ -5058,10 +5058,50 @@
50585058
"message": "OSD Profile {{profileNumber}}",
50595059
"description": "Content of the selector for the OSD Profile in the preview"
50605060
},
5061-
"osdSetupPreviewSelectFontElement": {
5062-
"message": "Font {{fontName}}",
5061+
"osdSetupPreviewSelectFont": {
5062+
"message": "Font",
50635063
"description": "Content of the selector for the OSD Font in the preview"
50645064
},
5065+
"osdSetupFontTypeDefault": {
5066+
"message": "Default",
5067+
"description": "Font Default"
5068+
},
5069+
"osdSetupFontTypeBold": {
5070+
"message": "Bold",
5071+
"description": "Font Bold"
5072+
},
5073+
"osdSetupFontTypeLarge": {
5074+
"message": "Large",
5075+
"description": "Font Large"
5076+
},
5077+
"osdSetupFontTypeLargeExtra": {
5078+
"message": "Large Extra",
5079+
"description": "Font Large Extra"
5080+
},
5081+
"osdSetupFontTypeBetaflight": {
5082+
"message": "Betaflight",
5083+
"description": "Font Betaflight"
5084+
},
5085+
"osdSetupFontTypeDigital": {
5086+
"message": "Digital",
5087+
"description": "Font Digital"
5088+
},
5089+
"osdSetupFontTypeClarity": {
5090+
"message": "Clarity",
5091+
"description": "Font Clarity"
5092+
},
5093+
"osdSetupFontTypeVision": {
5094+
"message": "Vision",
5095+
"description": "Font Vision"
5096+
},
5097+
"osdSetupFontTypeImpact": {
5098+
"message": "Impact",
5099+
"description": "Font Impact"
5100+
},
5101+
"osdSetupFontTypeImpactMini": {
5102+
"message": "Impact Mini",
5103+
"description": "Font Impact Mini"
5104+
},
50655105
"osdSetupPreviewCheckZoom": {
50665106
"message": "Zoom",
50675107
"description": "Check to select a bigger display of the OSD preview in small screens"

src/js/tabs/osd.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -1830,16 +1830,16 @@ OSD.constants = {
18301830

18311831
},
18321832
FONT_TYPES: [
1833-
{ file: "default", name: "Default" },
1834-
{ file: "bold", name: "Bold" },
1835-
{ file: "large", name: "Large" },
1836-
{ file: "extra_large", name: "Extra Large" },
1837-
{ file: "betaflight", name: "Betaflight" },
1838-
{ file: "digital", name: "Digital" },
1839-
{ file: "clarity", name: "Clarity" },
1840-
{ file: "vision", name: "Vision" },
1841-
{ file: "impact", name: "Impact" },
1842-
{ file: "impact_mini", name: "Impact Mini" },
1833+
{ file: "default", name: "osdSetupFontTypeDefault" },
1834+
{ file: "bold", name: "osdSetupFontTypeBold" },
1835+
{ file: "large", name: "osdSetupFontTypeLarge" },
1836+
{ file: "extra_large", name: "osdSetupFontTypeLargeExtra" },
1837+
{ file: "betaflight", name: "osdSetupFontTypeBetaflight" },
1838+
{ file: "digital", name: "osdSetupFontTypeDigital" },
1839+
{ file: "clarity", name: "osdSetupFontTypeClarity" },
1840+
{ file: "vision", name: "osdSetupFontTypeVision" },
1841+
{ file: "impact", name: "osdSetupFontTypeImpact" },
1842+
{ file: "impact_mini", name: "osdSetupFontTypeImpactMini" },
18431843
],
18441844
};
18451845

@@ -2666,11 +2666,14 @@ osd.initialize = function(callback) {
26662666
const option = $('<option>', {
26672667
"data-font-file": e.file,
26682668
value: e.file,
2669-
text: e.name,
2669+
text: i18n.getMessage(e.name),
26702670
});
26712671
fontPresetsElement.append($(option));
26722672
});
26732673

2674+
// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
2675+
fontPresetsElement.sortSelect(i18n.getMessage("osdSetupFontTypeDefault"));
2676+
26742677
const fontbuttons = $('.fontpresets_wrapper');
26752678
fontbuttons.append($('<button>', { class: "load_font_file", i18n: "osdSetupOpenFont" }));
26762679

@@ -3040,10 +3043,12 @@ osd.initialize = function(callback) {
30403043

30413044
// Standard fonts
30423045
OSD.constants.FONT_TYPES.forEach(function(e) {
3043-
const optionText = i18n.getMessage('osdSetupPreviewSelectFontElement', {fontName : e.name});
3044-
osdFontSelectorElement.append(new Option(optionText, e.file));
3046+
osdFontSelectorElement.append(new Option(i18n.getMessage(e.name), e.file));
30453047
});
30463048

3049+
// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
3050+
osdFontSelectorElement.sortSelect(i18n.getMessage("osdSetupFontTypeDefault"));
3051+
30473052
osdFontSelectorElement.change(function() {
30483053
// Change the font selected in the Font Manager, in this way it is easier to flash if the user likes it
30493054
osdFontPresetsSelectorElement.val(this.value).change();

src/tabs/osd.html

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ <h1 class="tab_title">
4343
<select class="osdprofile-selector">
4444
<!-- Populated at runtime -->
4545
</select>
46+
<label id="osdprofile-selector-font" i18n="osdSetupPreviewSelectFont"></label>
4647
<select class="osdfont-selector">
4748
<!-- Populated at runtime -->
4849
</select>

0 commit comments

Comments
 (0)