From af3a896aba552ed0abc1af6344719f5fe58ed60c Mon Sep 17 00:00:00 2001 From: Marek Blaha Date: Fri, 10 Nov 2023 12:42:04 +0100 Subject: [PATCH] Github action to retrieve translations from weblate This action clones weblate repository, retrieves fresh translations from it and commits the changes. --- .../weblate-pull-translations/action.yml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/actions/weblate-pull-translations/action.yml diff --git a/.github/actions/weblate-pull-translations/action.yml b/.github/actions/weblate-pull-translations/action.yml new file mode 100644 index 0000000000..240b66b5c8 --- /dev/null +++ b/.github/actions/weblate-pull-translations/action.yml @@ -0,0 +1,38 @@ +name: Retrieve *.po files from weblate repository + +runs: + using: "composite" + steps: + - name: Clone weblate repository + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }}-l10n + path: .l10n + + - name: Copy *.po files from weblate repository + shell: bash + run: | + pushd .l10n + for component in $(find . -mindepth 1 -maxdepth 1 -type d -not -path './.*'); do + source_path="" + if [ -f "${component}/PATH" ]; then + read -r source_path < "${component}/PATH" + for po in "${component}"/*.po; do + if [ -f "$po" ]; then + cp "${po}" "../${source_path}/" + fi + done + git -C .. add "${source_path}" + fi + done + popd + + - name: Cleanup the weblate repository + shell: bash + run: | + rm -rf .l10n + + - name: Commit *.po files + shell: bash + run: | + git -c user.name='GitHub Workflow' -c user.email='github-actions@github.com' commit -m "Update translations from weblate"