Skip to content

Commit

Permalink
build: move update-translations in script
Browse files Browse the repository at this point in the history
  • Loading branch information
flxzt committed Mar 30, 2024
1 parent f5751ee commit 942f600
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:
workflow_call:

name: Update Translation
name: Update Translations

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -35,18 +35,9 @@ jobs:
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Generate zh_Hant from zh_Hans
- name: Update translations
run: |
cat ./crates/rnote-ui/po/LINGUAS \
| sed -e 's|zh_Hans|zh_Hans\nzh_CN\nzh_SG|' \
-e 's|zh_Hant|zh_Hant\nzh_HK\nzh_TW|' \
| sort -uo ./crates/rnote-ui/po/LINGUAS
cat ./crates/rnote-ui/po/zh_Hans.po \
| sed -e 's|Language: zh_Hans|Language: zh_Hant|' \
-e 's|Last-Translator:|Last-Translator: openCC converted|' \
| opencc -c /usr/share/opencc/s2twp.json \
-o ./crates/rnote-ui/po/zh_Hant.po
bash ./build-aux/update-translations.sh
- name: Commit changes
id: commit-changes
Expand Down
4 changes: 3 additions & 1 deletion MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ unlock the weblate repo to resynchronize with upstream.

## Update the "Chinese Traditional" Translation (zh_Hant.po) Manually

The package providing the `opencc` tool (`opencc-tools` on Fedora) needs to be installed to regenerate the translation.

To autogenerate chinese traditional translation (`zh_Hant`) from chinese simplified (`zh_Hans`), use opencc:

```bash
opencc -i crates/rnote-ui/po/zh_Hans.po -o crates/rnote-ui/po/zh_Hant.po -c /usr/share/opencc/s2twp.json
./build-aux/update-translations.sh
```

discussed in [issue 220](https://github.com/flxzt/rnote/issues/220)
Expand Down
24 changes: 24 additions & 0 deletions build-aux/update-translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

script_dir=$(dirname "$0")

if ! command -v opencc &> /dev/null
then
echo "The 'opencc' tool needs to be installed and present in PATH"
exit 1
fi


# Regenerate 'zh_Hant' translation from 'zh_Hans'
sed \
-e 's|zh_Hans|zh_Hans\nzh_CN\nzh_SG|' \
-e 's|zh_Hant|zh_Hant\nzh_HK\nzh_TW|' \
"${script_dir}/../crates/rnote-ui/po/LINGUAS" \
| sort -uo "${script_dir}/../crates/rnote-ui/po/LINGUAS"

sed \
-e 's|Language: zh_Hans|Language: zh_Hant|' \
-e 's|Last-Translator:|Last-Translator: openCC converted|' \
"${script_dir}/../crates/rnote-ui/po/zh_Hans.po" \
| opencc -c /usr/share/opencc/s2twp.json \
-o "${script_dir}/../crates/rnote-ui/po/zh_Hant.po"
2 changes: 1 addition & 1 deletion crates/rnote-ui/po/LINGUAS
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ tr
uk
vi
zh_CN
zh_HK
zh_Hans
zh_Hant
zh_HK
zh_SG
zh_TW
6 changes: 3 additions & 3 deletions crates/rnote-ui/po/zh_Hant.po
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ msgid ""
"when this switch is off/on"
msgstr ""
"按住Ctrl鍵可暫時\n"
"啟用/禁用約束條件\n"
"啟用/停用約束條件\n"
"當此開關被關閉/開啟時"

#: crates/rnote-ui/data/ui/penssidebar/shaperpage.ui:327
Expand Down Expand Up @@ -1088,7 +1088,7 @@ msgstr "使用觸控繪製 [_T]"

#: crates/rnote-ui/data/ui/canvasmenu.ui:59
msgid "Block Pinch to _Zoom"
msgstr "禁用雙指縮放 [_Z]"
msgstr "停用雙指縮放 [_Z]"

#: crates/rnote-ui/data/ui/canvasmenu.ui:90
#: crates/rnote-ui/data/ui/shortcuts.ui:132
Expand Down Expand Up @@ -1254,7 +1254,7 @@ msgid ""
"gets disabled."
msgstr ""
"設定畫布上的觸控滾動是否為慣性滾動。\n"
"當這個選項被禁用時,\n"
"當這個選項被停用時,\n"
"應用程式需要重新啟動。"

#: crates/rnote-ui/data/ui/settingspanel.ui:72
Expand Down

0 comments on commit 942f600

Please sign in to comment.