mirror of https://github.com/sean1832/GPT-Brain
feat: add utility script to create and update languages
parent
3a1be4367e
commit
3f3f1b22cc
@ -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
|
@ -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)
|
@ -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
|
@ -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')
|
Loading…
Reference in New Issue