diff --git a/i18n/i18n.py b/i18n/i18n.py index dea98eca..81bc8bda 100644 --- a/i18n/i18n.py +++ b/i18n/i18n.py @@ -215,9 +215,7 @@ def bake_translations(): translations_array.append(slug) else: translations_array.append(translations[slug]) - language_code = ( - basename(translation_filename).split(".")[0].replace("-", "_") - ) + language_code = basename(translation_filename).split(".")[0][:2] # Write the individual translation table to a separate Python file in the 'translations' subfolder with open( diff --git a/src/krux/krux_settings.py b/src/krux/krux_settings.py index 5d861641..eabbae88 100644 --- a/src/krux/krux_settings.py +++ b/src/krux/krux_settings.py @@ -59,7 +59,10 @@ def t(slug): if not locale_control.translation: return slug slug_id = binascii.crc32(slug.encode("utf-8")) - translation_index = locale_control.reference.index(slug_id) + try: + translation_index = locale_control.reference.index(slug_id) + except: + return slug return locale_control.translation[translation_index] @@ -87,7 +90,7 @@ def load_locale(self, locale): self.reference = None self.translation = None return - module_path = "krux.translations.{}".format(locale.replace("-", "_")) + module_path = "krux.translations.{}".format(locale[:2]) translation_module = __import__(module_path) # Navigate to the nested module (translations.) for part in module_path.split(".")[1:]: diff --git a/src/krux/translations/__init__.py b/src/krux/translations/__init__.py index d7ef7a17..6c46f0bd 100644 --- a/src/krux/translations/__init__.py +++ b/src/krux/translations/__init__.py @@ -88,7 +88,6 @@ 2029624154, 3656120779, 3903754133, - 2433276713, 1272005728, 1022211991, 133139382, @@ -105,20 +104,12 @@ 3768416405, 602716148, 2365886561, - 167100211, - 1257161524, - 3285413280, - 3954726429, - 2741273573, - 1038288324, 2470115694, 712533907, 2736513298, 388908871, 563836138, 3981762528, - 2808868327, - 3138902155, 3663022166, 1963678224, 1583186953, @@ -138,9 +129,6 @@ 2739590230, 1310058127, 690625786, - 2669588306, - 589459321, - 3847882980, 1198393582, 3761518438, 2032416055, @@ -237,15 +225,12 @@ 1178563089, 1871146425, 2258131455, - 2940953674, - 2115024667, 3442025874, 3037062877, 4094072796, 1712856005, 1476462492, 262410364, - 4286144962, 3976793317, 3336226318, 1077771640, diff --git a/src/krux/translations/de_DE.py b/src/krux/translations/de.py similarity index 96% rename from src/krux/translations/de_DE.py rename to src/krux/translations/de.py index 2ea31670..ea9d8912 100644 --- a/src/krux/translations/de_DE.py +++ b/src/krux/translations/de.py @@ -77,7 +77,6 @@ "Bildschirmschonerzeit", "Abschaltzeit:", "Mnemonics ausblenden", - "Hash Flash at Boot", "Standard-Wallet", "Sicherheit", "Hardware", @@ -94,20 +93,12 @@ "Change:", "Go", "Werkseinstellungen wiederherstellen und neu starten?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "Suche nach SD-Karte..", "Einstellungen auf SD-Karte gespeichert.", "SD-Karte nicht erkannt.", "Änderungen bleiben bis zum Herunterfahren bestehen.", "Die Einstellungen werden intern auf Flash gespeichert.", "Werkeinstellungen", - "Set PIN", - "Disable PIN", "Links", "Rechts", "Thema ändern und neu starten?", @@ -127,9 +118,6 @@ "12 Wörter", "24 Wörter", "Doppelte Gedächtnisstütze", - "Current PIN", - "PIN", - "Invalid PIN", "Gute Entropie", "Schlechte Entropie", "Unzureichende Entropie", @@ -226,15 +214,12 @@ "%s wurde entfernt.", "Löschen Sie Ihre SD-Karte vollständig in einem anderen Gerät, um sicherzustellen, dass die Daten nicht wiederhergestellt werden können", "Um sicherzustellen, dass die Daten nicht wiederhergestellt werden können, verwenden Sie die Funktion 'Gerät löschen'", - "Generating Flash Hash..", - "Flash Hash", "Prüfe SD-Karte", "Drucke Test-QR", "Erstelle QR-Code", "Deskriptor-Adressen", "Mnemonic löschen", "Gerät löschen", - "Set a PIN first", "SD-Karte", "Belegt:", "Frei:", diff --git a/src/krux/translations/es_MX.py b/src/krux/translations/es.py similarity index 96% rename from src/krux/translations/es_MX.py rename to src/krux/translations/es.py index 55bad8e5..1ddd983a 100644 --- a/src/krux/translations/es_MX.py +++ b/src/krux/translations/es.py @@ -77,7 +77,6 @@ "Tiempo de Espera del Protector de Pantalla", "Tiempo de Apagado", "Ocultar Mnemónicos", - "Hash Flash at Boot", "Cartera Predeterminada", "Seguridad", "Hardware", @@ -94,20 +93,12 @@ "Cambio:", "Ir", "¿Restablecer a la configuración de fábrica y reiniciar?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "Comprobación de la tarjeta SD..", "Configuración almacenada en la tarjeta SD.", "Tarjeta SD no detectada.", "Los cambios durarán hasta que el dispositivo se apague.", "Ajustes almacenados internamente en flash.", "Ajustes de Fábrica", - "Set PIN", - "Disable PIN", "Izquierda", "Derecha", "¿Cambiar de tema y reiniciar?", @@ -127,9 +118,6 @@ "12 palabras", "24 palabras", "Doble mnemónico", - "Current PIN", - "PIN", - "Invalid PIN", "Buena entropía", "Baja entropía", "Entropía insuficiente", @@ -226,15 +214,12 @@ "%s eliminado.", "Borra completamente su tarjeta SD en otro dispositivo para asegurarse de que los datos sean irrecuperables", "Para garantizar que los datos no se puedan recuperar, utiliza la función de borrar dispositivo", - "Generating Flash Hash..", - "Flash Hash", "Verifica Tarjeta SD", "Prueba de Impresión QR", "Crear Código QR", "Direcciones del descriptor", "Eliminar Mnemónico", "Borrar Dispositivo", - "Set a PIN first", "Tarjeta SD", "Usado:", "Libre:", diff --git a/src/krux/translations/fr_FR.py b/src/krux/translations/fr.py similarity index 96% rename from src/krux/translations/fr_FR.py rename to src/krux/translations/fr.py index 615e8d99..b7a3d48b 100644 --- a/src/krux/translations/fr_FR.py +++ b/src/krux/translations/fr.py @@ -77,7 +77,6 @@ "Delai d'Inactivité", "Delai d'Arrêt", "Masquer les mnémoniques", - "Hash Flash at Boot", "Portefeuille par défaut", "Sécurité", "Matériel", @@ -94,20 +93,12 @@ "La monnaie\u2009:", "Go", "Restaurer les paramètres d'usine et redémarrer\u2009?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "Vérification de la carte SD..", "Paramètres stockés sur la carte SD.", "Carte SD non détectée.", "Les modifications dureront jusqu'à l'arrêt.", "Paramètres stockés en interne sur flash.", "Paramètres d'usine", - "Set PIN", - "Disable PIN", "Gauche", "À droite", "Changer de thème et redémarrer\u2009?", @@ -127,9 +118,6 @@ "12 mots", "24 mots", "Double mnémonique", - "Current PIN", - "PIN", - "Invalid PIN", "Bonne entropie", "Mauvaise entropie", "Entropie insuffisante", @@ -226,15 +214,12 @@ "%s supprimé.", "Effacez complètement votre carte SD dans un autre appareil pour assurer que les données soient irrécupérables", "Pour assurer que les données soient irrécupérables, utilisez la fonctionnalité 'Effacer l'appareil'", - "Generating Flash Hash..", - "Flash Hash", "Vérifiez la carte SD", "Test d'impression QR", "Créer du code QR", "Adresses des descripteurs", "Supprimer mnémonique", "Effacer l'appareil", - "Set a PIN first", "Carte SD", "Utilisé\u2009:", "Libre\u2009:", diff --git a/src/krux/translations/ko_KR.py b/src/krux/translations/ko.py similarity index 97% rename from src/krux/translations/ko_KR.py rename to src/krux/translations/ko.py index d9f3092d..f0470deb 100644 --- a/src/krux/translations/ko_KR.py +++ b/src/krux/translations/ko.py @@ -77,7 +77,6 @@ "화면보호기 시간", "자동 종료시간", "니모닉 숨기기", - "Hash Flash at Boot", "지갑 기본설정", "보안", "하드웨어", @@ -94,20 +93,12 @@ "변경", "선택", "공장 설정을 복원하고 재부팅하시겠습니까?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "SD카드 확인 중..", "SD 카드에 저장된 설정.", "SD카드가 감지되지 않았습니다.", "변경 사항은 종료될때까지 유지됩니다.", "설정은 플래시에서 내부적으로 저장됩니다.", "공장 초기 설정", - "Set PIN", - "Disable PIN", "왼쪽", "오른쪽", "테마를 변경하고 재부팅하시겠습니까?", @@ -127,9 +118,6 @@ "12단어", "24단어", "이중 니모닉", - "Current PIN", - "PIN", - "Invalid PIN", "엔트로피가 충분합니다", "엔트로피가 부족합니다", "엔트로피가 충분하지 않습니다", @@ -226,15 +214,12 @@ "%s 제거되었습니다.", "다른 장치에서 데이터 복구가 불가능하도록 SD카드를 완전히 지우십시오", "데이터 복구가 불가능하도록 장치 전체지우기 기능을 사용하십시오", - "Generating Flash Hash..", - "Flash Hash", "SD카드 확인", "QR 테스트 인쇄", "QR 코드 생성", "디스크립터 주소", "니모닉 제거", "기기 초기화", - "Set a PIN first", "SD카드", "이미 사용됨:", "여유 공간:", diff --git a/src/krux/translations/nl_NL.py b/src/krux/translations/nl.py similarity index 96% rename from src/krux/translations/nl_NL.py rename to src/krux/translations/nl.py index 4b379d22..37c8c29f 100644 --- a/src/krux/translations/nl_NL.py +++ b/src/krux/translations/nl.py @@ -77,7 +77,6 @@ "Schermbeveiligingstijd", "Uitschakelingstijd:", "Verberg geheugensteunen", - "Hash Flash at Boot", "Standaard portemonnee", "Beveiliging", "Hardware", @@ -94,20 +93,12 @@ "Wisselgeld:", "Ga", "Fabrieksinstellingen herstellen en opnieuw opstarten?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "SD kaart controleren..", "Instellingen opgeslagen op SD kaart.", "SD kaart niet gedetecteerd.", "Wijzigingen blijven van kracht tot afsluiten.", "Instellingen intern opgeslagen op flitser.", "Fabrieksinstellingen", - "Set PIN", - "Disable PIN", "Links", "Rechts", "Thema veranderen en opnieuw opstarten?", @@ -127,9 +118,6 @@ "12 woorden", "24 woorden", "Dubbel geheugensteuntje", - "Current PIN", - "PIN", - "Invalid PIN", "Goede entropie", "Slechte entropie", "Onvoldoende entropie", @@ -226,15 +214,12 @@ "%s verwijderd.", "Wis uw SD kaart volledig in een ander apparaat om te zorgen dat de gegevens onherstelbaar zijn", "Gebruik de functie 'Apparaat wissen' om te zorgen dat de gegevens onherstelbaar zijn", - "Generating Flash Hash..", - "Flash Hash", "Controleer SD kaart", "Test QR afdrukken", "QR code maken", "Descriptoradressen", "Geheugensteun verwijderen", "Apparaat wissen", - "Set a PIN first", "SD kaart", "Gebruikt:", "Vrij:", diff --git a/src/krux/translations/pt_BR.py b/src/krux/translations/pt.py similarity index 96% rename from src/krux/translations/pt_BR.py rename to src/krux/translations/pt.py index ee0bda86..df150ef5 100644 --- a/src/krux/translations/pt_BR.py +++ b/src/krux/translations/pt.py @@ -77,7 +77,6 @@ "Tempo para protetor de tela", "Tempo de desligamento", "Ocultar Mnemônicos", - "Hash Flash at Boot", "Carteira Padrão", "Segurança", "Hardware", @@ -94,20 +93,12 @@ "Troco:", "Ir", "Restaurar as configurações de fábrica e reiniciar?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "Verificando o cartão SD..", "Configurações armazenadas no cartão SD.", "Cartão SD não detectado.", "Alterações só durarão até o desligamento.", "Configurações armazenadas internamente no flash.", "Configurações de Fábrica", - "Set PIN", - "Disable PIN", "Esquerda", "Direita", "Mudar o tema e reiniciar?", @@ -127,9 +118,6 @@ "12 palavras", "24 palavras", "Duplo mnemônico", - "Current PIN", - "PIN", - "Invalid PIN", "Boa entropia", "Entropia fraca", "Entropia insuficiente", @@ -226,15 +214,12 @@ "removido.", "Apague totalmente seu cartão SD em outro dispositivo para garantir que os dados sejam irrecuperáveis", "Para garantir que os dados sejam irrecuperáveis, use o recurso Limpar Dispositivo", - "Generating Flash Hash..", - "Flash Hash", "Verifique o cartão SD", "Imprimir QR de teste", "Gerar Código QR", "Endereços do Descritor", "Excluir Mnemônico", "Limpar Dispositivo", - "Set a PIN first", "Cartão SD", "Usado:", "Livre:", diff --git a/src/krux/translations/ru_RU.py b/src/krux/translations/ru.py similarity index 97% rename from src/krux/translations/ru_RU.py rename to src/krux/translations/ru.py index 1ffe5fbb..50eac1a1 100644 --- a/src/krux/translations/ru_RU.py +++ b/src/krux/translations/ru.py @@ -77,7 +77,6 @@ "Время Экранной Заставки", "Время выключения", "Скрыть мнемоники", - "Hash Flash at Boot", "Кошелек по умолчанию", "Охрана", "Аппаратное Обеспечение", @@ -94,20 +93,12 @@ "Сдача:", "OK", "Восстановить заводские настройки и перезагрузить?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "Проверка SD карты..", "Настройки сохранены на SD-карте.", "SD карта не обнаружена.", "Изменения будут храниться до выключения.", "Настройки хранятся во флэш-памяти.", "Заводские Настройки", - "Set PIN", - "Disable PIN", "Влево", "Вправо", "Сменить тему и перезагрузить?", @@ -127,9 +118,6 @@ "12 слов", "24 слова", "Двойная мнемоника", - "Current PIN", - "PIN", - "Invalid PIN", "Хорошая энтропия", "Плохая энтропия", "Недостаточная энтропия", @@ -226,15 +214,12 @@ "%s удален.", "Полностью стерите SD-карту в другом устройстве, чтобы убедиться, что данные не восстановимы", "Для гарантии невосстановления данных используйте функцию Очистки Устройства", - "Generating Flash Hash..", - "Flash Hash", "Проверить SD Карту", "Напечатать Тестовый QR", "Создать QR Код", "Адреса дескрипторов", "Удалить Мнемонику", "Очистка Устройства", - "Set a PIN first", "SD карта", "Использовано:", "Свободно:", diff --git a/src/krux/translations/tr_TR.py b/src/krux/translations/tr.py similarity index 96% rename from src/krux/translations/tr_TR.py rename to src/krux/translations/tr.py index 710ecea4..5891c0ea 100644 --- a/src/krux/translations/tr_TR.py +++ b/src/krux/translations/tr.py @@ -77,7 +77,6 @@ "Ekran Koruyucu Süresi", "Kapanma Süresi", "Mnemonic'leri Gizle", - "Hash Flash at Boot", "Varsayılan Cüzdan", "Güvenlik", "Donanım", @@ -94,20 +93,12 @@ "Para Üstü:", "Seç", "Fabrika ayarlarına geri dönüp ve yeniden başlatılsın mı?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "SD kart kontrol ediliyor..", "Ayarlar SD karta kaydedildi.", "SD kart algılanmadı.", "Değişiklikler kapanışa kadar devam edecek.", "Ayarlar dahili olarak flaşta saklanır.", "Fabrika Ayarları", - "Set PIN", - "Disable PIN", "Sol", "Sağ", "Temayı değiştir ve yeniden başlat?", @@ -127,9 +118,6 @@ "12 kelime", "24 kelime", "Çifte anımsatıcı", - "Current PIN", - "PIN", - "Invalid PIN", "Yeterli entropi", "Düşük entropi", "Yetersiz entropi", @@ -226,15 +214,12 @@ "%s kaldırıldı.", "Verilerin geri kullanılamaz olduğundan emin olmak için SD kartınızı başka bir cihazda tamamen silin", "Verilerin geri kullanılamaz olduğundan emin olmak için Cihazı Sil özelliğini kullanın", - "Generating Flash Hash..", - "Flash Hash", "SD Kartı Kontrol Et", "Test QR'ını Yazdır", "QR Kodu Oluştur", "Tanımlayıcı Adresler", "Mnemonic'i Kaldır", "Cihazı Sil", - "Set a PIN first", "SD kart", "Kullanılan:", "Boş:", diff --git a/src/krux/translations/vi_VN.py b/src/krux/translations/vi.py similarity index 97% rename from src/krux/translations/vi_VN.py rename to src/krux/translations/vi.py index 1b6fed25..3b1d7edf 100644 --- a/src/krux/translations/vi_VN.py +++ b/src/krux/translations/vi.py @@ -77,7 +77,6 @@ "Thời gian chế độ bảo vệ màn hình", "Thời gian tắt máy", "Ẩn Mnemonics", - "Hash Flash at Boot", "Ví mặc định", "Bảo mật", "Phần cứng", @@ -94,20 +93,12 @@ "Thay đổi:", "Chọn", "Khôi phục cài đặt gốc và khởi động lại?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "Kiểm tra thẻ SD..", "Cài đặt được lưu trên thẻ SD.", "Thẻ SD không được phát hiện.", "Thay đổi sẽ kéo dài cho đến khi tắt máy.", "Cài đặt được lưu trữ nội bộ trên đèn flash.", "Cài đặt Gốc", - "Set PIN", - "Disable PIN", "Trái", "Phải", "Thay đổi giao diện và khởi động lại?", @@ -127,9 +118,6 @@ "12 từ", "24 từ", "Từ gợi nhớ kép", - "Current PIN", - "PIN", - "Invalid PIN", "Entropy tốt", "Entropy kém", "Không đủ entropy", @@ -226,15 +214,12 @@ "%s Đã bỏ.", "Xóa hoàn toàn thẻ SD trong một thiết bị khác để đảm bảo dữ liệu không thể phục hồi", "Sử dụng tính năng Xóa dữ liệu trên thiết bị để đảm bảo dữ liệu không thể phục hồi", - "Generating Flash Hash..", - "Flash Hash", "Kiểm tra thẻ SD", "In kiểm tra QR", "Tạo mã QR", "Địa chỉ người mô tả", "Xóa Mnemonic", "Xóa dữ liệu trên thiết bị", - "Set a PIN first", "Thẻ SD", "Đã sử dụng:", "Khả dụng:", diff --git a/src/krux/translations/zh_CN.py b/src/krux/translations/zh.py similarity index 96% rename from src/krux/translations/zh_CN.py rename to src/krux/translations/zh.py index 20bad0ba..1e167bee 100644 --- a/src/krux/translations/zh_CN.py +++ b/src/krux/translations/zh.py @@ -77,7 +77,6 @@ "屏保时间", "关机时间", "隐藏助记词", - "Hash Flash at Boot", "默认钱包", "安全", "硬件", @@ -94,20 +93,12 @@ "找零", "去", "恢复出厂设置并重新设备?", - "PIN disabled", - "Enter a 6+ characters PIN", - "Confirm PIN", - "PINs do not match", - "PIN set successfully", - "Error saving PIN", "检查 SD 卡..", "设置存储在SD卡上。", "未检测到 SD 卡。", "更改将在关机前保持。", "设置存储在 Flash 内部。", "出厂设置", - "Set PIN", - "Disable PIN", "左", "右", "更改主题并重新启动?", @@ -127,9 +118,6 @@ "12 单词", "24 单词", "双重助记词", - "Current PIN", - "PIN", - "Invalid PIN", "良好的熵", "熵值低", "熵不足", @@ -226,15 +214,12 @@ "已移除%s", "在其他设备中完全擦除您的 SD 卡以确保数据不可恢复", "要确保数据不可恢复,请使用擦除设备功能", - "Generating Flash Hash..", - "Flash Hash", "检查 SD 卡", "打印测试二维码", "创建二维码", "描述符地址", "删除助记词", "擦除设备", - "Set a PIN first", "SD 卡", "已用:", "空闲:", diff --git a/tests/pages/test_settings_page.py b/tests/pages/test_settings_page.py index e6f70fad..73cbbabc 100644 --- a/tests/pages/test_settings_page.py +++ b/tests/pages/test_settings_page.py @@ -17,11 +17,10 @@ def test_settings_m5stickv(m5stickv, mocker, mocker_printer): from krux.pages.settings_page import SettingsPage from krux.input import BUTTON_ENTER, BUTTON_PAGE, BUTTON_PAGE_PREV from krux.krux_settings import Settings, CategorySetting, NumberSetting - from krux.translations import translation_table + from krux.translations import available_languages - tlist = list(translation_table) - index_pt = tlist.index("pt-BR") - index_next = (index_pt + 1) % (len(tlist)) + index_pt = available_languages.index("pt-BR") + index_next = (index_pt + 1) % (len(available_languages)) cases = [ ( # 0 - Change Network @@ -83,7 +82,7 @@ def test_settings_m5stickv(m5stickv, mocker, mocker_printer): BUTTON_PAGE, BUTTON_ENTER, ), - lambda: Settings().i18n.locale == tlist[index_next], + lambda: Settings().i18n.locale == available_languages[index_next], ), ( # 3 Printer numeric settings ( @@ -186,17 +185,25 @@ def test_settings_on_amigo_tft(amigo, mocker, mocker_printer): import krux from krux.pages.settings_page import SettingsPage from krux.input import BUTTON_TOUCH - from krux.krux_settings import Settings, CategorySetting, NumberSetting - from krux.translations import translation_table - from krux.themes import WHITE, RED, GREEN, ORANGE - - tlist = list(translation_table) - index_pt = tlist.index("pt-BR") - index_next = (index_pt + 1) % (len(tlist)) - text_pt = translation_table[tlist[index_pt]][1177338798] + "\n" + tlist[index_pt] - text_next = ( - translation_table[tlist[index_next]][1177338798] + "\n" + tlist[index_next] - ) + from krux.krux_settings import Settings, CategorySetting + from krux.translations import available_languages, ref_array + from krux.translations.pt import translation_array as br_array + from krux.themes import WHITE, GREEN, ORANGE + + index_pt = available_languages.index("pt-BR") + index_next = (index_pt + 1) % (len(available_languages)) + slug_index = ref_array.index(1177338798) + text_pt = br_array[slug_index] + "\n" + available_languages[index_pt] + + # Get translations for the next language + next_language = available_languages[index_next] + # Construct the path to the nested module + next_module_path = f"krux.translations.{next_language[:2]}" + # Import the top-level module (krux) + next_trans_module = __import__(next_module_path, fromlist=[""]) + # Access the translation_array variable from the nested module + next_trans_array = getattr(next_trans_module, "translation_array") + text_next = next_trans_array[slug_index] + "\n" + available_languages[index_next] PREV_INDEX = 0 GO_INDEX = 1 @@ -272,7 +279,7 @@ def test_settings_on_amigo_tft(amigo, mocker, mocker_printer): mocker.call(text_pt, WHITE), mocker.call(text_next, WHITE), ], - lambda: Settings().i18n.locale == tlist[index_next], + lambda: Settings().i18n.locale == available_languages[index_next], CategorySetting, ), ] diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 431d7cb2..633991d5 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -1,39 +1,35 @@ import pytest +# import binascii -@pytest.fixture -def tdata(mocker): - import binascii +# TRANSLATION_SLUGS = [ +# "Hello world", +# "Hello", +# "Untranslated slug", +# ] - return [ - {"en-US": {binascii.crc32("Hello world".encode("utf-8")): "Hello"}}, - {"es-MX": {binascii.crc32("Hello world".encode("utf-8")): "Hola"}}, - ] +# INDEX_REFERENCE = [ +# binascii.crc32(TRANSLATION_SLUGS[0].encode("utf-8")), +# binascii.crc32(TRANSLATION_SLUGS[1].encode("utf-8")), +# binascii.crc32(TRANSLATION_SLUGS[2].encode("utf-8")), +# ] +# PT_BR = [ +# "Olá mundo", +# "Olá", +# "Untranslated slug", +# ] -def test_translations(mocker, m5stickv, tdata): - import binascii - from krux.krux_settings import translations - cases = [ - (tdata[0], {binascii.crc32("Hello world".encode("utf-8")): "Hello"}), - (tdata[1], None), - ] - for case in cases: - mocker.patch("krux.krux_settings.translation_table", case[0]) - lookup = translations("en-US") +def test_translations(mocker, m5stickv): + from krux.krux_settings import t, locale_control - assert lookup == case[1] + # Test default language + assert t("Load Mnemonic") == "Load Mnemonic" + # Test pt_BR + locale_control.load_locale("pt_BR") + assert t("Load Mnemonic") == "Carregar Mnemônico" -def test_t(mocker, m5stickv, tdata): - from krux.krux_settings import t - - cases = [ - (tdata[0], "Hello world", "Hello"), - (tdata[1], "Hello world", "Hello world"), - ] - for case in cases: - mocker.patch("krux.krux_settings.translation_table", case[0]) - - assert t(case[1]) == case[2] + # Test non existent slug + assert t("New Text") == "New Text"