diff --git a/batch-programs/create_language_base.bat b/batch-programs/create_language_base.bat new file mode 100644 index 0000000..517f717 --- /dev/null +++ b/batch-programs/create_language_base.bat @@ -0,0 +1,13 @@ +@echo off +cd.. + +echo Activating Virtural environment... +call .\venv\Scripts\activate + +echo creating language base... +call python .\batch-programs\create_language_base.py + +cls +echo language base created! + +pause \ No newline at end of file diff --git a/batch-programs/create_language_base.py b/batch-programs/create_language_base.py new file mode 100644 index 0000000..a2c1ec8 --- /dev/null +++ b/batch-programs/create_language_base.py @@ -0,0 +1,31 @@ +import os +import subprocess +import sys +# Add the parent directory to the Python path +parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +sys.path.append(parent_dir) + +from modules import utilities as util + + +pages = util.scan_directory(f'pages') +pages_full = [] +for page in pages: + page = util.get_file_name(page, extension=True) + pages_full.append(f'pages/{page}') +main_file = util.get_file_name(f'Seanium_brain.py', extension=True) + +pages_full.append(main_file) + +pages_flatten = ' '.join(pages_full) + +locals_path = f'.locals' +languages = util.read_json(f'{locals_path}/languages.json') +# create LC_MESSAGES under .local directory if not exist +for language in languages.values(): + # if language path not exist, create it + if not os.path.exists(f'{locals_path}/{language}/LC_MESSAGES'): + os.makedirs(f'{locals_path}/{language}/LC_MESSAGES') + +# create .pot file +subprocess.call(f'xgettext {pages_flatten} -o {locals_path}/base.pot', shell=True) diff --git a/batch-programs/updage_language.bat b/batch-programs/updage_language.bat new file mode 100644 index 0000000..b9188c0 --- /dev/null +++ b/batch-programs/updage_language.bat @@ -0,0 +1,12 @@ +@echo off +cd.. + +echo Activating Virtural environment... +call .\venv\Scripts\activate + +echo creating language base... +call python .\batch-programs\create_language_base.py + +echo updating .po files... +call python .\batch-programs\update_language.py +pause \ No newline at end of file diff --git a/batch-programs/update_language.py b/batch-programs/update_language.py new file mode 100644 index 0000000..993d599 --- /dev/null +++ b/batch-programs/update_language.py @@ -0,0 +1,20 @@ +import os +import subprocess +import sys + +# Add the parent directory to the Python path +parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +sys.path.append(parent_dir) + +from modules import utilities as util + +locals_path = f'.locals' +languages = util.read_json(f'{locals_path}/languages.json') + +try: + # create LC_MESSAGES under .local directory if not exist + for language in languages.values(): + subprocess.call(f'msgmerge -U {locals_path}/{language}/LC_MESSAGES/base.po {locals_path}/base.pot', shell=True) +except Exception as e: + print(e) + print('Error: Unable to merge .pot file with .po files') \ No newline at end of file