From ebdacbc2b2ac48e137dd9a1409aa334512e2fb62 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 26 Nov 2022 18:11:28 +0100 Subject: [PATCH] Make sure translation are in sync The new script makes sure that strings files don't contain obsolete strings but also ease the job of contributors by adding missing translations as comments. A Github Action ensures that translations stay in sync over time. --- .github/workflows/check-translations.yml | 16 +++++++++ res/values-cs/strings.xml | 8 +++++ res/values-de/strings.xml | 10 +++--- res/values-es/strings.xml | 16 +++++++++ res/values-fr/strings.xml | 8 +++++ res/values-it/strings.xml | 8 +++++ res/values-ko/strings.xml | 16 +++++++++ res/values-lv/strings.xml | 2 ++ res/values-pt/strings.xml | 8 +++++ res/values-ru/strings.xml | 15 ++++++++- res/values-tr/strings.xml | 13 ++++++++ res/values-zh-rCN/strings.xml | 2 +- sync_translations.py | 41 ++++++++++++++++++++++++ 13 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/check-translations.yml create mode 100644 sync_translations.py diff --git a/.github/workflows/check-translations.yml b/.github/workflows/check-translations.yml new file mode 100644 index 0000000..82d87c6 --- /dev/null +++ b/.github/workflows/check-translations.yml @@ -0,0 +1,16 @@ +name: Check translations + +on: + workflow_dispatch: + push: + pull_request: + +jobs: + check-translations: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - run: python3 sync_translations.py + - name: Check that strings files are uptodate, run python3 sync_translations.py otherwise + run: git diff --exit-code diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index e332475..b89f38b 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -4,14 +4,21 @@ Klávesnice Unexpected Nastavení Klávesnice Unexpected Rozvržení + Změnit rozvržení klávesnice V nastavení systému (Univerzální) Diakritická znaménka Zobrazovat znaménka pro všechny instalované systémové jazyky Zobrazovat znaménka pouze pro současně zvolený jazyk Skrýt (univerzální) diakritická znaménka + + + + Automatická kapitalizace Stiskne Shift na začátku věty + + Žádné Psaní Vzdálenost posunutí prstem @@ -36,6 +43,7 @@ Tmavý Světlý Černý + Velmi krátká Krátká Běžná diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 9b49e57..2a14053 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -4,6 +4,7 @@ Unexpected Keyboard Unexpected Keyboard - Einstellungen Layout + Tastaturlayout ändern Systemeinstellung Akzente @@ -14,11 +15,12 @@ Nie Nur im Querformat Immer - Zusätzliche Zeichen zur Tastatur hinzufügen - Keines - Tippen Automatische Großschreibung Shift-Taste am Satzanfang aktivieren + Zusätzliche Zeichen zur Tastatur hinzufügen + + Keines + Tippen Länge der Wischgeste Abstand der Zeichen in den Ecken der Tasten (%s) Zeitüberschreitung bei Tastenwiederholung @@ -34,7 +36,7 @@ Höhe der Tastatur Höhe der Tastatur im Querformat Horizontaler Abstand - Größe der Beschriftung + Größe der Beschriftung Größe der Buchstaben auf den Tasten (%.2fx) Theme Systemeinstellung diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 274a2e8..5a2e813 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -1,13 +1,25 @@ + + Ajustes de Unexpected Keyboard Formato + Cambiar formato de teclado Ajustes del sistema Acentos Mostrar acentos para todos los lenguajes instalados Solo mostrar acentos para el lenguaje seleccionado Ocultar acentos + + + + + + + + + Escribiendo Distancia para deslizar Distancia de caracteres en las esquinas de las letras (%s) @@ -17,9 +29,12 @@ Habilitar/deshabilitar vibración al presionar una tecla Movimientos de cursor preciso Modular la velocidad de repetición de teclas según si se desliza más o menos + + Estilo Margen del pie Altura del teclado + Margen horizontal Tamaño de etiqueta Tamaño de caracteres mostrados en el teclado (%.2fx) @@ -28,6 +43,7 @@ Oscuro Claro Negro + Muy corto Corto Normal diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 05c0d83..ba38e16 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -1,7 +1,10 @@ + + Unexpected Keyboard Paramètres Disposition + Disposition des touches Paramètre système Accents @@ -14,6 +17,9 @@ Toujour Majuscule automatique Active Shift au début des phrases + + + Saisie Distance de swipe La distance des caractères dans les coins (%s) @@ -23,6 +29,8 @@ Vibration a chaque touche Mouvement précis du curseur Modifier la vitesse de répétition en bougeant le doigt + + Style Marge du bas Hauteur du clavier diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index dd44bd9..26cad56 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -4,14 +4,21 @@ Unexpected Keyboard Impostazioni di Unexpected Keyboard Layout + Cambia layout tastiera Impostazioni di sistema Accenti Mostra accenti per tutte le lingue installate Mostra accenti solo per le lingue selezionate Nascondi accenti + + + + Maiuscole Automatiche Premi Shift all\'inizio di una frase + + Nessuno Digitando Distanza swipe @@ -36,6 +43,7 @@ Scuro Chiaro Nero + Veramente breve Breve Normale diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 22262de..217af01 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -1,13 +1,25 @@ + + Unexpected Keyboard 설정 레이아웃 + 키보드 레이아웃 변경 시스템 세팅 악센트 설치된 모든 언어의 악센트 표시 선택한 언어의 악센트만 표시 모든 언어의 악센트 숨기기 + + + + + + + + + 타자 스와이프 범위 키 모서리 문자의 입력 범위 (%s) @@ -17,9 +29,12 @@ 키 누를 때 진동 키거/끄기 정확한 커서 움직임 더 많거나 적은 스와이프로 키 반복 조절 + + 스타일 아래 넓이 키보드 높이 + 양 옆 넓이 폰트 크기 키보드의 표시되는 폰트 크기 (%.2fx) @@ -28,6 +43,7 @@ Dark Light Black + 매우 짧음 짧음 보통 diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index aa6356c..1fe8d63 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -4,6 +4,7 @@ Unexpected Keyboard Unexpected Keyboard iestatījumi Izkārtojums + Mainīt tastatūras izkārtojumu Ierīces iestatījumi Uzsvara zīmes @@ -17,6 +18,7 @@ Automātiski lielie burti Piespiest Shift teikuma sākumā Pievienot tastatūrai taustiņus + Neviens Rakstīšana Pavilkšanas attālums diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index f008079..c6a1014 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -4,14 +4,21 @@ Teclado Unexpected Configurar Teclado Unexpected Layout + Mudar layout do teclado Mesmo do sistema Acentos Mostrar acentos para todos os idiomas instalados Mostrar acentos só para o idioma selecionado Ocultar acentos + + + + Maiusculização automática Aciona o shift no início de cada frase + + Nenhum Digitação Distância a deslizar @@ -36,6 +43,7 @@ Escuro Claro Preto + Muito curto Curto Normal diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index a7a41f3..84f771b 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -1,14 +1,24 @@ - Unexpected Keyboard + + Unexpected Keyboard Настройки Расположение + Изменить раскладку клавиатуры Системные настройки Акцент Показывать акценты для всех установленных языков Показывать акценты только для выбранного языка Скрыть акценты + + + + + + + + Нету Печатание Расстояние пролистывания @@ -19,6 +29,8 @@ Включение/выключение вибрации при нажатии клавиши Точные перемещения курсора Модулируйте скорость повторения клавиш, проводя пальцем больше или меньше + + Стиль Нижняя граница поля Высота клавиатуры @@ -31,6 +43,7 @@ Темный Светлый Черный + Очень короткий Короткий Обычный diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index e858307..5332b68 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -4,12 +4,21 @@ Unexpected Keyboard Unexpected Keyboard Ayarları Düzen + Klavye Düzenini Değiştir Sistem Ayarları Aksanlar Yüklü tüm dillerin aksanlarını göster Sadece seçili dilin aksanlarını göster Aksanları gizle + + + + + + + + Hiçbiri Yazma Kaydırma mesafesi @@ -20,9 +29,12 @@ Tuşa basıldığında titreşimi etkinleştir İmleç hareketini ayarla Tuş tekrar hızını az ya da çok kaydırarak ayarla + + Stil Alt boşluk Klavye yüksekliği + Yatay boşluk Etiket boyutu Klavye üzerinde gösterilecek karakter boyutu (%.2fx) @@ -31,6 +43,7 @@ Koyu Açık Siyah + Çok kısa Kısa Normal diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index f0078e1..698eecf 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -3,8 +3,8 @@ Unexpected Keyboard (debug) Unexpected Keyboard Unexpected Keyboard 设置 - 调整字母亮度 布局 + 调整字母亮度 改变键盘布局 系统设置 声调 diff --git a/sync_translations.py b/sync_translations.py new file mode 100644 index 0000000..b76b8d1 --- /dev/null +++ b/sync_translations.py @@ -0,0 +1,41 @@ +import xml.etree.ElementTree as ET +from xml.sax import saxutils +import glob + +# Edit every strings.xml files: +# - Add missing translation as comments +# - Remove obsolete strings +# - Sort in the same order as the baseline +# The baseline is 'values/strings.xml', which is english. + +def parse_strings_file(file): + resources = ET.parse(file).getroot() + return [ + ((ent.get("name"), ent.get("product")), ent.text) + for ent in resources if ent.tag == "string" + ] + +def string_entry_str(name, text, product): + product_attr = ' product="%s"' % product if product != None else "" + text_encoded = saxutils.escape(text) + return '%s' % (name, product_attr, text_encoded) + +def write_updated_strings(out, baseline, strings): + out.write('\n\n') + for key, default_text in baseline: + name, product = key + if key in strings: + ent = string_entry_str(name, strings[key], product) + out.write(" %s\n" % ent) + else: + def_ent = string_entry_str(name, default_text, product) + out.write(" \n" % def_ent) + out.write('\n') + +baseline = parse_strings_file("res/values/strings.xml") + +for strings_file in glob.glob("res/values-*/strings.xml"): + print(strings_file) + strings = dict(parse_strings_file(strings_file)) + with open(strings_file, "w") as out: + write_updated_strings(out, baseline, strings)