check translations updated - working
This commit is contained in:
parent
06c97339d6
commit
2b5006ff0f
@ -2,43 +2,49 @@ 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)
|
||||
# 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)
|
||||
|
||||
# Assuming the _en.lex file exists
|
||||
if en_file is None:
|
||||
print(f"No _en.lex file found for module: {modulename}")
|
||||
return
|
||||
# Assuming the _en.lex file exists
|
||||
if en_file is None:
|
||||
print(f"No _en.lex file found for module: {modulename}")
|
||||
return
|
||||
|
||||
# Read translation pairs from the _en file
|
||||
translations = {}
|
||||
with open(os.path.join(base_en_path, en_file), 'r', encoding='utf-8') as en_f:
|
||||
for line in en_f:
|
||||
if '=>' in line:
|
||||
key, message = line.split('=>', 1)
|
||||
translations[key.strip().strip("'")] = message.strip().strip(",").strip("'")
|
||||
# Read translation pairs from the _en file
|
||||
translations = {}
|
||||
with open(os.path.join(base_en_path, en_file), 'r', encoding='utf-8') as en_f:
|
||||
for line in en_f:
|
||||
if '=>' in line:
|
||||
key, message = line.split('=>', 1)
|
||||
translations[key.strip().strip("'")] = message.strip().strip(",").strip("'")
|
||||
|
||||
# Compare against each lex file in the locale directory
|
||||
for lex_file in lex_files:
|
||||
with open(os.path.join(base_locale_path, lex_file), 'r', encoding='utf-8') as loc_f:
|
||||
for line in loc_f:
|
||||
if '=>' in line:
|
||||
key, message = line.split('=>', 1)
|
||||
key = key.strip().strip("'")
|
||||
message = message.strip().strip(",").strip("'")
|
||||
# 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)
|
||||
key = key.strip().strip("'")
|
||||
message = message.strip().strip(",").strip("'")
|
||||
|
||||
# Checking for missing translations
|
||||
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}'")
|
||||
else:
|
||||
print(f"Key '{key}' not found in _en.lex for module '{modulename}'.")
|
||||
# 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 == '':
|
||||
print(f"Missing translation in module '{modulename}', ({language_code})', key '{key}'")
|
||||
else:
|
||||
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.")
|
||||
|
Loading…
Reference in New Issue
Block a user