mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Remove stale strings + add test for string inconsistencies
This commit is contained in:
parent
d0c569eead
commit
a012369164
6 changed files with 69 additions and 20 deletions
|
@ -38,7 +38,7 @@
|
||||||
"websocket_request_expected": "期望一个WebSocket请求",
|
"websocket_request_expected": "期望一个WebSocket请求",
|
||||||
"cannot_open_file": "不能打开文件{file:s}(原因:{error:s})",
|
"cannot_open_file": "不能打开文件{file:s}(原因:{error:s})",
|
||||||
"cannot_write_file": "写入文件{file:s}失败(原因:{error:s})",
|
"cannot_write_file": "写入文件{file:s}失败(原因:{error:s})",
|
||||||
"unknown_error_reading_file": "尝试读取文件{files}时发生未知错误(原因:{errors})",
|
"unknown_error_reading_file": "尝试读取文件{file:s}时发生未知错误(原因:{error:s})",
|
||||||
"corrupted_json": "从{ressource:s}读取的JSON损坏(原因:{error:s})",
|
"corrupted_json": "从{ressource:s}读取的JSON损坏(原因:{error:s})",
|
||||||
"corrupted_yaml": "从{ressource:s}读取的YMAL损坏(原因:{error:s})",
|
"corrupted_yaml": "从{ressource:s}读取的YMAL损坏(原因:{error:s})",
|
||||||
"error_writing_file": "写入文件{file:s}失败:{error:s}",
|
"error_writing_file": "写入文件{file:s}失败:{error:s}",
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
"invalid_password": "Invalid password",
|
"invalid_password": "Invalid password",
|
||||||
"invalid_token": "Invalid token - please authenticate",
|
"invalid_token": "Invalid token - please authenticate",
|
||||||
"invalid_usage": "Invalid usage, pass --help to see help",
|
"invalid_usage": "Invalid usage, pass --help to see help",
|
||||||
"ldap_attribute_already_exists": "Attribute '{attribute}' already exists with value '{value}'",
|
|
||||||
"ldap_server_down": "Unable to reach LDAP server",
|
|
||||||
"logged_in": "Logged in",
|
"logged_in": "Logged in",
|
||||||
"logged_out": "Logged out",
|
"logged_out": "Logged out",
|
||||||
"not_logged_in": "You are not logged in",
|
"not_logged_in": "You are not logged in",
|
||||||
|
@ -54,6 +52,5 @@
|
||||||
"command_unknown": "Command '{command:s}' unknown?",
|
"command_unknown": "Command '{command:s}' unknown?",
|
||||||
"warn_the_user_about_waiting_lock": "Another YunoHost command is running right now, we are waiting for it to finish before running this one",
|
"warn_the_user_about_waiting_lock": "Another YunoHost command is running right now, we are waiting for it to finish before running this one",
|
||||||
"warn_the_user_about_waiting_lock_again": "Still waiting...",
|
"warn_the_user_about_waiting_lock_again": "Still waiting...",
|
||||||
"warn_the_user_that_lock_is_acquired": "The other command just completed, now starting this command",
|
"warn_the_user_that_lock_is_acquired": "The other command just completed, now starting this command"
|
||||||
"ldap_server_is_down_restart_it": "The LDAP service is down, attempt to restart it..."
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@
|
||||||
"websocket_request_expected": "Richiesta WebSocket attesa",
|
"websocket_request_expected": "Richiesta WebSocket attesa",
|
||||||
"cannot_open_file": "Impossibile aprire il file {file:s} (motivo: {error:s})",
|
"cannot_open_file": "Impossibile aprire il file {file:s} (motivo: {error:s})",
|
||||||
"cannot_write_file": "Impossibile scrivere il file {file:s} (motivo: {error:s})",
|
"cannot_write_file": "Impossibile scrivere il file {file:s} (motivo: {error:s})",
|
||||||
"unknown_error_reading_file": "Errore sconosciuto durante il tentativo di leggere il file {file:s} (motivo: {errore:s})",
|
"unknown_error_reading_file": "Errore sconosciuto durante il tentativo di leggere il file {file:s} (motivo: {error:s})",
|
||||||
"corrupted_json": "Lettura JSON corrotta da {resource:s} (motivo: {error:s})",
|
"corrupted_json": "Lettura JSON corrotta da {ressource:s} (motivo: {error:s})",
|
||||||
"corrupted_yaml": "Lettura YAML corrotta da {resource:s} (motivo: {error:s})",
|
"corrupted_yaml": "Lettura YAML corrotta da {ressource:s} (motivo: {error:s})",
|
||||||
"error_writing_file": "Errore durante la scrittura del file {file:s}: {error:s}",
|
"error_writing_file": "Errore durante la scrittura del file {file:s}: {error:s}",
|
||||||
"error_removing": "Errore durante la rimozione {path:s}: {error:s}",
|
"error_removing": "Errore durante la rimozione {path:s}: {error:s}",
|
||||||
"error_changing_file_permissions": "Errore durante il cambio di permessi per {path:s}: {error:s}",
|
"error_changing_file_permissions": "Errore durante il cambio di permessi per {path:s}: {error:s}",
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
"warn_the_user_that_lock_is_acquired": "L'altro comando è appena completato, ora avvio questo comando",
|
"warn_the_user_that_lock_is_acquired": "L'altro comando è appena completato, ora avvio questo comando",
|
||||||
"warn_the_user_about_waiting_lock_again": "Sto ancora aspettando ...",
|
"warn_the_user_about_waiting_lock_again": "Sto ancora aspettando ...",
|
||||||
"warn_the_user_about_waiting_lock": "Un altro comando YunoHost è in esecuzione in questo momento, stiamo aspettando che finisca prima di eseguire questo",
|
"warn_the_user_about_waiting_lock": "Un altro comando YunoHost è in esecuzione in questo momento, stiamo aspettando che finisca prima di eseguire questo",
|
||||||
"corrupted_toml": "TOML corrotto da {ressource:s} (motivo: {errore:s})",
|
"corrupted_toml": "TOML corrotto da {ressource:s} (motivo: {error:s})",
|
||||||
"invalid_token": "Token non valido: autenticare",
|
"invalid_token": "Token non valido: autenticare",
|
||||||
"session_expired": "La sessione è terminata. Sei pregato di autenticarti nuovamente.",
|
"session_expired": "La sessione è terminata. Sei pregato di autenticarti nuovamente.",
|
||||||
"ldap_server_is_down_restart_it": "Il servizio LDAP è terminato, provo a riavviarlo..."
|
"ldap_server_is_down_restart_it": "Il servizio LDAP è terminato, provo a riavviarlo..."
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"websocket_request_expected": "Forventet en WebSocket-forespørsel",
|
"websocket_request_expected": "Forventet en WebSocket-forespørsel",
|
||||||
"warning": "Advarsel:",
|
"warning": "Advarsel:",
|
||||||
"values_mismatch": "Verdiene samsvarer ikke",
|
"values_mismatch": "Verdiene samsvarer ikke",
|
||||||
"unknown_user": "Ukjent '{group}' bruker",
|
"unknown_user": "Ukjent '{user}' bruker",
|
||||||
"unknown_group": "Ukjent '{group}' gruppe",
|
"unknown_group": "Ukjent '{group}' gruppe",
|
||||||
"unable_authenticate": "Kunne ikke identitetsbekrefte",
|
"unable_authenticate": "Kunne ikke identitetsbekrefte",
|
||||||
"success": "Vellykket.",
|
"success": "Vellykket.",
|
||||||
|
|
|
@ -30,21 +30,21 @@
|
||||||
"warn_the_user_that_lock_is_acquired": "diğer komut şimdi tamamlandı, şimdi bu komutu başlatıyor",
|
"warn_the_user_that_lock_is_acquired": "diğer komut şimdi tamamlandı, şimdi bu komutu başlatıyor",
|
||||||
"warn_the_user_about_waiting_lock_again": "Hala bekliyor...",
|
"warn_the_user_about_waiting_lock_again": "Hala bekliyor...",
|
||||||
"warn_the_user_about_waiting_lock": "Başka bir YunoHost komutu şu anda çalışıyor, bunu çalıştırmadan önce bitmesini bekliyoruz",
|
"warn_the_user_about_waiting_lock": "Başka bir YunoHost komutu şu anda çalışıyor, bunu çalıştırmadan önce bitmesini bekliyoruz",
|
||||||
"command_unknown": "'{Command:s}' komutu bilinmiyor mu?",
|
"command_unknown": "'{command:s}' komutu bilinmiyor mu?",
|
||||||
"download_bad_status_code": "{url:s} döndürülen durum kodu {code:s}",
|
"download_bad_status_code": "{url:s} döndürülen durum kodu {code:s}",
|
||||||
"download_unknown_error": "{url:s} adresinden veri indirilirken hata oluştu: {error:s}",
|
"download_unknown_error": "{url:s} adresinden veri indirilirken hata oluştu: {error:s}",
|
||||||
"download_timeout": "{url:s} yanıtlaması çok uzun sürdü, pes etti.",
|
"download_timeout": "{url:s} yanıtlaması çok uzun sürdü, pes etti.",
|
||||||
"download_ssl_error": "{url:s} ağına bağlanırken SSL hatası",
|
"download_ssl_error": "{url:s} ağına bağlanırken SSL hatası",
|
||||||
"invalid_url": "Geçersiz url {url:s} (bu site var mı?)",
|
"invalid_url": "Geçersiz url {url:s} (bu site var mı?)",
|
||||||
"error_changing_file_permissions": "{Path:s} için izinler değiştirilirken hata oluştu: {error:s}",
|
"error_changing_file_permissions": "{path:s} için izinler değiştirilirken hata oluştu: {error:s}",
|
||||||
"error_removing": "{Path:s} kaldırılırken hata oluştu: {error:s}",
|
"error_removing": "{path:s} kaldırılırken hata oluştu: {error:s}",
|
||||||
"error_writing_file": "{File:s} dosyası yazılırken hata oluştu: {error:s}",
|
"error_writing_file": "{file:s} dosyası yazılırken hata oluştu: {error:s}",
|
||||||
"corrupted_toml": "{Ressource:s} kaynağından okunan bozuk toml (nedeni: {hata:s})",
|
"corrupted_toml": "{ressource:s} kaynağından okunan bozuk toml (nedeni: {error:s})",
|
||||||
"corrupted_yaml": "{Ressource:s} kaynağından bozuk yaml okunuyor (nedeni: {error:s})",
|
"corrupted_yaml": "{ressource:s} kaynağından bozuk yaml okunuyor (nedeni: {error:s})",
|
||||||
"corrupted_json": "{Ressource:s} adresinden okunan bozuk json (nedeni: {error:s})",
|
"corrupted_json": "{ressource:s} adresinden okunan bozuk json (nedeni: {error:s})",
|
||||||
"unknown_error_reading_file": "{File:s} dosyasını okumaya çalışırken bilinmeyen hata (nedeni: {error:s})",
|
"unknown_error_reading_file": "{file:s} dosyasını okumaya çalışırken bilinmeyen hata (nedeni: {error:s})",
|
||||||
"cannot_write_file": "{File:s} dosyası yazılamadı (nedeni: {error:s})",
|
"cannot_write_file": "{file:s} dosyası yazılamadı (nedeni: {error:s})",
|
||||||
"cannot_open_file": "{File:s} dosyası açılamadı (nedeni: {error:s})",
|
"cannot_open_file": "{file:s} dosyası açılamadı (nedeni: {error:s})",
|
||||||
"unknown_user": "Bilinmeyen '{user}' kullanıcı",
|
"unknown_user": "Bilinmeyen '{user}' kullanıcı",
|
||||||
"unknown_group": "Bilinmeyen '{group}' grubu",
|
"unknown_group": "Bilinmeyen '{group}' grubu",
|
||||||
"invalid_usage": "Geçersiz kullanım, yardım görmek için --help iletin",
|
"invalid_usage": "Geçersiz kullanım, yardım görmek için --help iletin",
|
||||||
|
|
52
test/test_translation_format_consistency.py
Normal file
52
test/test_translation_format_consistency.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
import glob
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
# List all locale files (except en.json being the ref)
|
||||||
|
locale_folder = "locales/"
|
||||||
|
locale_files = glob.glob(locale_folder + "*.json")
|
||||||
|
locale_files = [filename.split("/")[-1] for filename in locale_files]
|
||||||
|
locale_files.remove("en.json")
|
||||||
|
|
||||||
|
reference = json.loads(open(locale_folder + "en.json").read())
|
||||||
|
|
||||||
|
|
||||||
|
def find_inconsistencies(locale_file):
|
||||||
|
|
||||||
|
this_locale = json.loads(open(locale_folder + locale_file).read())
|
||||||
|
|
||||||
|
# We iterate over all keys/string in en.json
|
||||||
|
for key, string in reference.items():
|
||||||
|
|
||||||
|
# Ignore check if there's no translation yet for this key
|
||||||
|
if key not in this_locale:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Then we check that every "{stuff}" (for python's .format())
|
||||||
|
# should also be in the translated string, otherwise the .format
|
||||||
|
# will trigger an exception!
|
||||||
|
subkeys_in_ref = set(k[0] for k in re.findall(r"{(\w+)(:\w)?}", string))
|
||||||
|
subkeys_in_this_locale = set(
|
||||||
|
k[0] for k in re.findall(r"{(\w+)(:\w)?}", this_locale[key])
|
||||||
|
)
|
||||||
|
|
||||||
|
if any(k not in subkeys_in_ref for k in subkeys_in_this_locale):
|
||||||
|
yield """\n
|
||||||
|
==========================
|
||||||
|
Format inconsistency for string {key} in {locale_file}:"
|
||||||
|
en.json -> {string}
|
||||||
|
{locale_file} -> {translated_string}
|
||||||
|
""".format(
|
||||||
|
key=key,
|
||||||
|
string=string.encode("utf-8"),
|
||||||
|
locale_file=locale_file,
|
||||||
|
translated_string=this_locale[key].encode("utf-8"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("locale_file", locale_files)
|
||||||
|
def test_translation_format_consistency(locale_file):
|
||||||
|
inconsistencies = list(find_inconsistencies(locale_file))
|
||||||
|
if inconsistencies:
|
||||||
|
raise Exception("".join(inconsistencies))
|
Loading…
Add table
Reference in a new issue