From 942f6007a629cfe71cdaa03db931e3e9232806a5 Mon Sep 17 00:00:00 2001 From: Felix Zwettler Date: Sat, 30 Mar 2024 14:24:46 +0100 Subject: [PATCH] build: move update-translations in script --- ...ranslation.yml => update-translations.yml} | 15 +++--------- MAINTAINING.md | 4 +++- build-aux/update-translations.sh | 24 +++++++++++++++++++ crates/rnote-ui/po/LINGUAS | 2 +- crates/rnote-ui/po/zh_Hant.po | 6 ++--- 5 files changed, 34 insertions(+), 17 deletions(-) rename .github/workflows/{update-translation.yml => update-translations.yml} (75%) create mode 100755 build-aux/update-translations.sh diff --git a/.github/workflows/update-translation.yml b/.github/workflows/update-translations.yml similarity index 75% rename from .github/workflows/update-translation.yml rename to .github/workflows/update-translations.yml index 374ed0d682..dfbed52d45 100644 --- a/.github/workflows/update-translation.yml +++ b/.github/workflows/update-translations.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: workflow_call: -name: Update Translation +name: Update Translations concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -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 diff --git a/MAINTAINING.md b/MAINTAINING.md index 387301a487..1815cfeae3 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -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) diff --git a/build-aux/update-translations.sh b/build-aux/update-translations.sh new file mode 100755 index 0000000000..f2332e842c --- /dev/null +++ b/build-aux/update-translations.sh @@ -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" diff --git a/crates/rnote-ui/po/LINGUAS b/crates/rnote-ui/po/LINGUAS index 00ecaee0bb..d63e37cf56 100644 --- a/crates/rnote-ui/po/LINGUAS +++ b/crates/rnote-ui/po/LINGUAS @@ -30,8 +30,8 @@ tr uk vi zh_CN -zh_HK zh_Hans zh_Hant +zh_HK zh_SG zh_TW diff --git a/crates/rnote-ui/po/zh_Hant.po b/crates/rnote-ui/po/zh_Hant.po index 72630f818f..86925f00a4 100644 --- a/crates/rnote-ui/po/zh_Hant.po +++ b/crates/rnote-ui/po/zh_Hant.po @@ -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 @@ -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 @@ -1254,7 +1254,7 @@ msgid "" "gets disabled." msgstr "" "設定畫布上的觸控滾動是否為慣性滾動。\n" -"當這個選項被禁用時,\n" +"當這個選項被停用時,\n" "應用程式需要重新啟動。" #: crates/rnote-ui/data/ui/settingspanel.ui:72