diff --git a/.github/workflows/i18n-translations.yml b/.github/workflows/i18n-translations.yml new file mode 100644 index 0000000..bb48718 --- /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 ca8bc77..ded5423 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 0000000..8c05491 --- /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 1518132..59c9f3c 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';