check translations updated - working

This commit is contained in:
Brian Read 2024-07-21 11:47:14 +01:00
parent 06c97339d6
commit 2b5006ff0f

View File

@ -2,13 +2,13 @@ import os
import argparse
def find_lex_files(modulename):
base_locale_path = f"/home/brianr/Documents/smeserver-manager-locale/root/usr/share/smanager/lib/SrvMngr/I18n/Modules/{modulename}/"
base_en_path = f"/home/brianr/Documents/smeserver-manager/root/usr/share/smanager/lib/SrvMngr/I18n/Modules/{modulename}/"
base_locale_path = f"/home/brianr//Documents/smeserver-manager-locale/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/{modulename}/"
base_en_path = f"/home/brianr//Documents/smeserver-manager/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/{modulename}/"
# Get all .lex files in the specified directory
lex_files = [f for f in os.listdir(base_locale_path) if f.endswith('.lex')]
# Find the corresponding _en.lex file
en_file = next((f for f in os.listdir(base_en_path) if f.endswith('._en.lex')), None)
en_file = next((f for f in os.listdir(base_en_path) if f.endswith('_en.lex')), None)
# Assuming the _en.lex file exists
if en_file is None:
@ -25,7 +25,11 @@ def find_lex_files(modulename):
# Compare against each lex file in the locale directory
for lex_file in lex_files:
#Skip any english lang file in there (there might be one)
if lex_file.endswith('_en.lex'):
continue
with open(os.path.join(base_locale_path, lex_file), 'r', encoding='utf-8') as loc_f:
print(f"File:{lex_file}")
for line in loc_f:
if '=>' in line:
key, message = line.split('=>', 1)
@ -33,12 +37,14 @@ def find_lex_files(modulename):
message = message.strip().strip(",").strip("'")
# Checking for missing translations
language_code = lex_file.split('.')[0][-2:] # Extracting language code from filename
#print(f"{lex_file} {language_code}")
#quit()
if key in translations:
if message == translations[key] or message == '':
language_code = lex_file.split('.')[-2] # Extracting language code from filename
print(f"Missing translation in module '{modulename}', language '{language_code}', key '{key}'")
print(f"Missing translation in module '{modulename}', ({language_code})', key '{key}'")
else:
print(f"Key '{key}' not found in _en.lex for module '{modulename}'.")
print(f"Key '{key}' not found in english lex for module '{modulename} ({language_code})'.")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check for missing translations in lex files.")