-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DoctorReid
committed
Jun 16, 2024
1 parent
3a3dec4
commit b0dce4e
Showing
10 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Compile po into mo | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev_locale | ||
|
||
jobs: | ||
job1: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.11"] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: pip install polib==1.2.0 | ||
|
||
- name: Show dir | ||
run: pwd | ||
|
||
- name: Compile PO files | ||
run: | | ||
PYTHONPATH=$(pwd) python your_script.py python src/one_dragon/devtools/compile_po.py | ||
- name: Commit changes | ||
run: | | ||
if ! git diff --quiet; then | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add data/locales/**/*.mo | ||
git commit -m "#2 自动编译mo文件提交 $(date +%Y-%m-%d)" | ||
git push | ||
else | ||
echo "No file modifications" | ||
fi |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# extra requirements that development or deployment needs | ||
pyinstaller==6.7.0 | ||
pip-tools==7.4.1 | ||
polib==1.2.0 # i18 compile .mo file into .po file | ||
pyinstaller==6.7.0 # package into exe | ||
pip-tools==7.4.1 # use pip-compile |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
|
||
import polib | ||
|
||
from one_dragon.utils import os_utils | ||
|
||
|
||
def compile_lang(model: str, lang: str): | ||
""" | ||
将特定语言的文件编译成mo文件 | ||
:param model: 模块 不同模块的多语言文本区分 | ||
:param lang: 语言 cn | ||
:return: None | ||
""" | ||
base_dir = os_utils.get_path_under_work_dir('assets', 'text') | ||
po_file_path = os.path.join(base_dir, model, '%s.po' % lang) | ||
|
||
output_dir = os_utils.get_path_under_work_dir('assets', 'text', 'output', lang, 'LC_MESSAGES') | ||
mo_file_path = os.path.join(output_dir, '%s.mo' % model) | ||
|
||
po = polib.pofile(po_file_path) | ||
po.save_as_mofile(mo_file_path) | ||
|
||
|
||
def compile_po_files(): | ||
""" | ||
将不同语言的po文件编译成mo | ||
:return: | ||
""" | ||
for model in ['ocr', 'ui']: | ||
for lang in ['cn', 'en']: | ||
compile_lang(model, lang) | ||
|
||
|
||
if __name__ == '__main__': | ||
compile_po_files() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters