Skip to content

Commit

Permalink
move to pybabel
Browse files Browse the repository at this point in the history
  • Loading branch information
shun2wang committed Dec 17, 2023
1 parent e60bf36 commit 4eb948b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ def main():
sys.exit(0)
elif opt in ('-o', '--output-file'):
outfile = arg
# do it
# do it
if not args:
print('No input file given', file=sys.stderr)
print("Try `msgfmt --help' for more information.", file=sys.stderr)
return

for filename in args:
print("----------------------------------------------")
print(filename, outfile)
make(filename, outfile)


Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/translation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,41 @@ jobs:
with:
python-version: "3.10"

# - name: Update .po tiles
# run: |
# sudo pip install Babel
# set -x
# find -name messages.pot
# messages_pot=$(find -name messages.pot)
# pybabel update --input-file="$messages_pot" --output-dir="${{ github.workspace }}/psychopy/app/locale"

# - name: Compiling .mo files
# run: |
# set -x
# for x in ${{ github.workspace }}/psychopy/app/locale/*/*/*.po ;\
# do python3 .github/workflows/msgfmt.py --output-file "`dirname "$x"`/`basename "$x" .po`.mo" "$x" ; \
# done

- name: Compiling .mo files
run: |
set -x
for x in ${{ github.workspace }}/psychopy/app/locale/*/*/*.po ;\
do python .github/workflows/msgfmt.py --output-file "`dirname "$x"`/`basename "$x"`" "$x.mo" ; \
do pybabel compile -i $x -o "$x".mo; \
done
- name: Stage all changes
id: staging
run: |
ls -d ${{ github.workspace }}/psychopy/app/locale/*/*/*.mo | grep -v "en-GB" | xargs git add -f
ls -d ${{ github.workspace }}/psychopy/app/locale/*/*/*.mo \
| grep -v "/en_US/" | xargs git add .
echo "NUM_OF_STAGED=$(git diff --staged --name-only | wc -l)" >> $GITHUB_OUTPUT
- name: Push translation changes
if: steps.staging.outputs.NUM_OF_STAGED > 0
run: |
git config user.name github-actions
git config user.email github-actions@github.com
ls -d ${{ github.workspace }}/psychopy/app/locale/*/*/*.mo | grep -v "en-GB" | xargs git add
ls -d ${{ github.workspace }}/psychopy/app/locale/*/*/*.mo \
| grep -v "/en_US/" | xargs git add .
git commit -m "[bot] Docs: Update translations"
git push
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*.so
*.egg
.eggs
psychopy/app/locale/**/LC_MESSAGE/messages.mo
#psychopy/app/locale/**/LC_MESSAGE/messages.mo

# Python files #
################
Expand Down
4 changes: 2 additions & 2 deletions psychopy/app/locale/zh_CN/LC_MESSAGE/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ msgstr ""

#: __init__.py:48
msgid "Welcome to PsychoPy2!"
msgstr "欢迎使用 PsychoPy"
msgstr "欢迎使用 PsychoPy!"

#: ../alerts/_alerts.py:121 ../alerts/_alerts.py:123
msgid "msg"
Expand Down Expand Up @@ -7113,7 +7113,7 @@ msgstr ""

#: ../monitors/MonitorCenter.py:401
msgid "Get Photometer"
msgstr 获取光度计""
msgstr "获取光度计"

#: ../monitors/MonitorCenter.py:407
msgid "Gamma Calibration..."
Expand Down

0 comments on commit 4eb948b

Please sign in to comment.