Skip to content

Commit

Permalink
feat: Initial support for UA language translation (#4415)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Feerick <[email protected]>
  • Loading branch information
philmoz and pfeerick authored Jan 25, 2024
1 parent baaf722 commit b40c40d
Show file tree
Hide file tree
Showing 42 changed files with 7,033 additions and 24 deletions.
1 change: 1 addition & 0 deletions companion/src/firmwares/opentx/opentxinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class OpenTxFirmware: public Firmware
addLanguage("se");
addLanguage("sk");
addLanguage("tw");
addLanguage("ua");
}

virtual Firmware * getFirmwareVariant(const QString & id);
Expand Down
33 changes: 23 additions & 10 deletions companion/src/generaledit/generalsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,32 @@ void GeneralSetupPanel::populateBacklightCB()
void GeneralSetupPanel::populateVoiceLangCB()
{
QComboBox * b = ui->voiceLang_CB;
QString strings[] = { tr("English"), tr("Danish"), tr("Dutch"), tr("French"), tr("Italian"), tr("German"),
tr("Czech"), tr("Slovak"), tr("Spanish"), tr("Polish"), tr("Portuguese"), tr("Russian"),
tr("Swedish"), tr("Hungarian"), tr("Chinese"), tr("Japanese"), tr("Hebrew"), NULL};

// Note: these align with the radio NOT computer locales - TODO harmonise with ISO and one list!!!
QString langcode[] = { "en", "da", "nl","fr", "it", "de",
"cz", "sk", "es", "pl", "pt", "ru",
"se", "hu", "cn", "jp", "he", NULL};
static QString strings[][2] = {
{ tr("Chinese"), "cn" },
{ tr("Czech"), "cz" },
{ tr("Danish"), "da" },
{ tr("Dutch"), "nl" },
{ tr("English"), "en" },
{ tr("French"), "fr" },
{ tr("German"), "de" },
{ tr("Hebrew"), "he" },
{ tr("Hungarian"), "hu" },
{ tr("Italian"), "it" },
{ tr("Japanese"), "jp" },
{ tr("Polish"), "pl" },
{ tr("Portuguese"), "pt" },
{ tr("Russian"), "ru" },
{ tr("Slovak"), "sk" },
{ tr("Spanish"), "es" },
{ tr("Swedish"), "se" },
{ tr("Ukrainian"), "ua" },
{ NULL, NULL }};

b->clear();
for (int i=0; strings[i]!=NULL; i++) {
b->addItem(strings[i],langcode[i]);
if (generalSettings.ttsLanguage == langcode[i]) {
for (int i=0; strings[i][0]!=NULL; i++) {
b->addItem(strings[i][0],strings[i][1]);
if (generalSettings.ttsLanguage == strings[i][1]) {
b->setCurrentIndex(b->count()-1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ include(CMakeForceCompiler)
include(Bitmaps)

set(PCB_TYPES X9LITE X9LITES X7 XLITE XLITES X9D X9D+ X9E X10 X12S NV14 PL18)
set(RADIO_LANGUAGES CN CZ DA DE EN ES FI FR HE IT JP PT RU SK SE PL HU NL TW)
set(TTS_LANGUAGES CN CZ DA DE EN ES FR HE IT JP PT RU SK SE PL HU NL)
set(RADIO_LANGUAGES CN CZ DA DE EN ES FI FR HE IT JP PT RU SK SE PL HU NL TW UA)
set(TTS_LANGUAGES CN CZ DA DE EN ES FR HE IT JP PT RU SK SE PL HU NL UA)

set(PCB "X9D+" CACHE STRING "Radio type, one of: ${PCB_TYPES}")
set_property(CACHE PCB PROPERTY STRINGS ${PCB_TYPES})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import sys

def is_ru_char(char):
def is_cyrillic_char(char):
if '\u0400' <= char <= '\u04FF':
return True

return False

def extract_ru_characters(file_path):
ru_characters = set()
def extract_cyrillic_characters(file_path):
cyrillic_characters = set()

with open(file_path, mode='r', encoding='utf-8') as file:
for line in file:
for char in line:
if is_ru_char(char):
ru_characters.add(char)
if is_cyrillic_char(char):
cyrillic_characters.add(char)

return ru_characters
return cyrillic_characters

def convert_to_unicode(ru_characters):
def convert_to_unicode(cyrillic_characters):
unicode_list = []

for char in ru_characters:
for char in cyrillic_characters:
unicode_list.append(hex(ord(char)))

return unicode_list
Expand All @@ -31,8 +31,8 @@ def format_output(unicode_list):


file_path = sys.argv[1]
ru_chars = extract_ru_characters(file_path)
unicode_list = convert_to_unicode(ru_chars)
cyrillic_chars = extract_cyrillic_characters(file_path)
unicode_list = convert_to_unicode(cyrillic_chars)
formatted_output = format_output(unicode_list)

print(formatted_output)
697 changes: 697 additions & 0 deletions radio/src/fonts/lvgl/lv_font_arimo_ua_13.c

Large diffs are not rendered by default.

Loading

0 comments on commit b40c40d

Please sign in to comment.