Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MTM-62062] Add translation workflow #59

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/i18n-translations.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ Thumbs.db

# Cypress videos
cypress/videos

# Exclude auto-generated locale files
/locales
26 changes: 26 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
11 changes: 10 additions & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Loading