diff --git a/.github/workflows/compare_translations.py b/.github/workflows/compare_translations.py index 384f25e28b..d8c0aff797 100644 --- a/.github/workflows/compare_translations.py +++ b/.github/workflows/compare_translations.py @@ -58,23 +58,35 @@ FileTranslation = namedtuple("FileTranslation", ["file", "missing_translations"]) -def compare_translations(default_translation, other_translation): - """Compare two translations and print missing keys. +def compare_translations(default_translation, other_translation, default_file, other_file): + """Compare two translations and return detailed info about missing/mismatched keys. Args: - default_translation: The default translation - other_translation: The other translation + default_translation (dict): The default translation (en.json). + other_translation (dict): The other language translation. + default_file (str): The name of the default translation file. + other_file (str): The name of the other translation file. Returns: - missing_translations: List of missing translations + list: A list of detailed error messages for each missing/mismatched key. """ - missing_translations = [] + errors = [] + # Check for missing keys in other_translation for key in default_translation: if key not in other_translation: - missing_translations.append(key) + error_msg = f"Missing Key: '{key}' - This key from '{default_file}' is missing in '{other_file}'." + errors.append(error_msg) + + # Check for keys in other_translation that don't match any in default_translation + for key in other_translation: + if key not in default_translation: + error_msg = f"Error Key: '{key}' - This key in '{other_file}' does not match any key in '{default_file}'." + errors.append(error_msg) + + return errors + - return missing_translations def load_translation(filepath): @@ -95,39 +107,32 @@ def load_translation(filepath): def check_translations(directory): """Load default translation and compare with other translations. - Args: + Args: directory (str): The directory containing translation files. Returns: None """ - default_translation = load_translation("lang/en.json") - translations_dir = directory - translations = os.listdir(translations_dir) - translations.remove("en.json") # Exclude default translation + default_file = "en.json" + default_translation = load_translation(os.path.join(directory, default_file)) + translations = os.listdir(directory) + translations.remove(default_file) # Exclude default translation - files_with_missing_translations = [] + error_found = False for translation_file in translations: - translation_path = os.path.join(translations_dir, translation_file) - other_translation = load_translation(translation_path) - - # Compare translations - missing_translations = compare_translations( - default_translation, other_translation - ) - if missing_translations: - file_translation = FileTranslation(translation_file, missing_translations) - files_with_missing_translations.append(file_translation) - - for file_translation in files_with_missing_translations: - print( - f"File {translations_dir}/{file_translation.file} has missing translations for:" - ) - for key in file_translation.missing_translations: - print(f" - {key}") - - if files_with_missing_translations: + other_file = os.path.join(directory, translation_file) + other_translation = load_translation(other_file) + + # Compare translations and get detailed error messages + errors = compare_translations(default_translation, other_translation, default_file, translation_file) + if errors: + error_found = True + print(f"File {translation_file} has missing translations for:") + for error in errors: + print(f" - {error}") + + if error_found: sys.exit(1) # Exit with an error status code else: print("All translations are present") diff --git a/lang/de.json b/lang/de.json index d903796ca1..740a2fb83d 100644 --- a/lang/de.json +++ b/lang/de.json @@ -152,7 +152,6 @@ "Logout": "Ausloggen", "Settings": "Einstellungen", "Dark Theme": "Dunkles Thema", - "Error": "Fout", "Warning": "Waarschuwing", "Information": "Informatie", diff --git a/lang/en.json b/lang/en.json index 09bdd9211f..c7cf4c0b77 100644 --- a/lang/en.json +++ b/lang/en.json @@ -12,7 +12,6 @@ "Enter your password": "Enter your password", "Forgot password": "Forgot password", "Login": "Login", - "Notification Feature is not installed": "Notification Feature is not installed", "Sit back relax, we'll": "Sit back relax, we'll", "Recover": "Recover", @@ -35,7 +34,6 @@ "Next": "Next", "Request Sent to": "Request Sent to", "Log out": "Log out", - "Error": "Error", "Warning": "Warning", "Information": "Information", @@ -46,7 +44,6 @@ "Collaborate": "Collaborate", "with your": "with your", "Organizations": "Organizations", - "Title from the viewMode GSoC branch": "Title from the viewMode GSoC branch", "Please verify URL first": "Please verify URL first", "Enter a valid URL": "Enter a valid URL", @@ -61,20 +58,16 @@ "Password must not contain spaces": "Password must not contain spaces", "Password does not match original": "Password does not match original", "Join Organisation": "Join Organisation", - "We're": "We're", "Glad": "Glad", "you're": "you're", "Back": "Back", - "Let's": "Let's", "get": "get", "you": "you", "SignUp": "SignUp", - "Please wait": "Please wait", "for organisation(s) to accept your invitation.": "for organisation(s) to accept your invitation.", - "Add Event Title": "Add Event Title", "Where is the event": "Where is the event", "Add Location": "Add Location", diff --git a/lang/es.json b/lang/es.json index d1060a09b5..9401739d42 100644 --- a/lang/es.json +++ b/lang/es.json @@ -14,9 +14,7 @@ "Login": "Acceso", "Sit back relax, we'll": "Siéntese, ", "Recover": "", - "Notification Feature is not installed": "La función de notificación no está instalada", - "your password": "relájese, recuperaremos su contraseña", "Recover Password": "Recupera tu contraseña", "Select Language": "Seleccione el idioma", diff --git a/lang/fr.json b/lang/fr.json index 6db60cd069..8bea3b769d 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -7,10 +7,8 @@ "Enter new password": "Entrez un nouveau mot de passe", "Re-Enter your password": "Entrez à nouveau votre mot de passe", "Change Password": "Changer le mot de passe", - "Email Hint": "test@test.org", "Notification Feature is not installed": "La fonction de notification n'est pas installée", - "Enter your registered Email": "Entrez votre email enregistré", "Enter your password": "Tapez votre mot de passe", "Forgot password": "Mot de passe oublié", @@ -36,7 +34,6 @@ "Next": "Suivante", "Request Sent to": "Demande envoyée à", "Log out": "Se déconnecter", - "Join": "Rejoignez", "and": "et", "Collaborate": "collaborez", @@ -61,7 +58,6 @@ "Password must not contain spaces": "Le mot de passe ne doit pas contenir d'espaces", "Password does not match original": "Le mot de passe ne correspond pas à l'original", "Join Organisation": "Rejoindre l'organisation", - "We're": "Nous sommes", "Glad": "heureux que vous", "you're": "soyez de", diff --git a/lang/ja.json b/lang/ja.json index 98b00fe3f8..22953de4f8 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -14,7 +14,6 @@ "Login": "ログイン", "Sit back relax, we'll": "ゆったりとおくつろぎください。", "Recover": "回復", - "Notification Feature is not installed": "通知機能がインストールされていません", "your password": "あなたのパスワード", "Recover Password": "パスワードを回復", @@ -62,10 +61,8 @@ "get": "得る", "you": "あなた", "SignUp": "サインアップ", - "Please wait": "お待ちください", "for organisation(s) to accept your invitation.": "組織があなたの招待を受け入れるために。", - "Add Event Title": "イベントタイトルを追加", "Where is the event": "イベントはどこですか", "Add Location": "場所を追加", diff --git a/lang/pt.json b/lang/pt.json index 1bd61aad6b..1dafd483fa 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -13,9 +13,7 @@ "Forgot password": "Esqueceu sua senha", "Login": "Conecte-se", "Sit back relax, we'll": "Sente-se relaxe, vamos", - "Notification Feature is not installed": "O recurso de notificação não está instalado", - "Recover": "Recuperar", "your password": "sua senha", "Recover Password": "Recuperar senha", diff --git a/lang/zh.json b/lang/zh.json index ef0a204878..3f587f4cfe 100644 --- a/lang/zh.json +++ b/lang/zh.json @@ -15,7 +15,6 @@ "Sit back relax, we'll": "高枕无忧, ", "Recover": "", "Notification Feature is not installed": "未安装通知功能\n", - "your password": "我们会找回您的密码", "Recover Password": "恢复你的密码", "Select Language": "选择语言",