From 73c083dfa6a3e2e80753127a1a8d809df73b282d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Rynarzewski?= Date: Tue, 17 Dec 2024 15:32:17 +0100 Subject: [PATCH] feat: [MTM-62062] Add translation workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Rynarzewski --- .github/workflows/i18n-translations.yml | 47 +++++++++++++++++++++++++ .gitignore | 3 ++ crowdin.yml | 26 ++++++++++++++ src/i18n.ts | 11 +++++- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/i18n-translations.yml create mode 100644 crowdin.yml diff --git a/.github/workflows/i18n-translations.yml b/.github/workflows/i18n-translations.yml new file mode 100644 index 00000000..bb487180 --- /dev/null +++ b/.github/workflows/i18n-translations.yml @@ -0,0 +1,47 @@ +name: Handle translations + +on: + workflow_dispatch: + inputs: + branch: + description: Branch to handle translations for. + required: false + default: main + +jobs: + handle_translations: + runs-on: ubuntu-latest + steps: + - name: Get GitHub token for c8y-i18n-automations app + id: i18n-automations-token + uses: Cumulocity-IoT/github-app-token@v3 + with: + app_id: ${{ vars.C8Y_I18N_APP_ID }} + installation_id: ${{ vars.C8Y_I18N_INSTALLATION_ID }} + private_key: ${{ secrets.C8Y_I18N_PRIVATE_KEY }} + + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + token: ${{ steps.i18n-automations-token.outputs.token }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Extract source files + run: ng extract-i18n + + - name: Run i18n-automation action + id: i18n-automation + uses: Cumulocity-IoT/i18n-automation@main + env: + CROWDIN_PROJECT_ID: ${{ vars.CROWDIN_PROJECT_ID }} + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} + DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }} + GITHUB_TOKEN: ${{ steps.i18n-automations-token.outputs.token }} diff --git a/.gitignore b/.gitignore index ca8bc77a..ded5423a 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ Thumbs.db # Cypress videos cypress/videos + +# Exclude auto-generated locale files +/locales diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 00000000..8c054914 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,26 @@ +project_id_env: "CROWDIN_PROJECT_ID" +api_token_env: "CROWDIN_API_TOKEN" + +preserve_hierarchy: false + +files: [ + { + "source": "/locales/locales.pot", + "translation": "/src/locales/%locale_with_underscore%.po", + + "languages_mapping": { + "locale_with_underscore": { + "de": "de", + "es-ES": "es", + "fr": "fr", + "ja": "ja_JP", + "ko": "ko", + "nl": "nl", + "pl": "pl", + "pt-BR": "pt_BR", + "zh-CN": "zh_CN", + "zh-TW": "zh_TW" + } + } + } +] diff --git a/src/i18n.ts b/src/i18n.ts index 15181326..59c9f3cd 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -3,4 +3,13 @@ * You can always add additional strings by adding your own po file. All po files are * combined to one JSON file per language and are loaded if the specific language is needed. */ -import './locales/de.po'; // <- adding additional strings to the german translation. +import './locales/de.po'; +// import './locales/es.po'; +// import './locales/fr.po'; +// import './locales/ja_JP.po'; +// import './locales/ko.po'; +// import './locales/nl.po'; +// import './locales/pl.po'; +// import './locales/pt_BR.po'; +// import './locales/zh_CN.po'; +// import './locales/zh_TW.po';