From 768d4c07900c9e3cc6112c43b7fc234e3cd4bca2 Mon Sep 17 00:00:00 2001 From: shafin-deriv Date: Mon, 29 Apr 2024 11:00:56 +0800 Subject: [PATCH 1/2] feat: crowdin translation workflows --- .github/actions/test_build/action.yml | 19 +++++++++++++++++ .github/workflows/coveralls.yml | 2 +- .github/workflows/translation_pull.yml | 29 ++++++++++++++++++++++++++ .github/workflows/translation_push.yml | 23 ++++++++++++++++++++ crowdin.yml | 23 ++++++++++++++++++++ docusaurus.config.js | 7 ++++++- 6 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 .github/actions/test_build/action.yml create mode 100644 .github/workflows/translation_pull.yml create mode 100644 .github/workflows/translation_push.yml create mode 100644 crowdin.yml diff --git a/.github/actions/test_build/action.yml b/.github/actions/test_build/action.yml new file mode 100644 index 00000000..44e59998 --- /dev/null +++ b/.github/actions/test_build/action.yml @@ -0,0 +1,19 @@ +name: build +description: Build Docusaurus project +inputs: + NODE_ENV: + description: Node environment + required: false + default: staging + TRACKJS_TOKEN: + description: Trackjs Token + required: false +runs: + using: composite + steps: + - name: Building Docusaurus project + env: + NODE_ENV: ${{ inputs.NODE_ENV }} + TRACKJS_TOKEN: ${{ inputs.TRACKJS_TOKEN }} + run: npm run build -- --locale en + shell: bash diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index d0f16ffd..4c56e6f3 100755 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies uses: './.github/actions/npm_install_from_cache' - name: Build - uses: ./.github/actions/build + uses: ./.github/actions/test_build - name: Run Tests run: npm run test -- --collectCoverage - name: Coveralls diff --git a/.github/workflows/translation_pull.yml b/.github/workflows/translation_pull.yml new file mode 100644 index 00000000..e6d967a6 --- /dev/null +++ b/.github/workflows/translation_pull.yml @@ -0,0 +1,29 @@ +name: Crowdin Action + +on: + workflow_dispatch: + +permissions: write-all + +jobs: + crowdin: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - name: Synchronize with Crowdin + uses: crowdin/github-action@v1 + with: + upload_sources: false + upload_translations: false + download_translations: true + localization_branch_name: l18n_crowdin_translations + create_pull_request: true + pull_request_title: 'New Crowdin translations' + pull_request_body: 'New Crowdin pull request with translations' + pull_request_base_branch_name: 'master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} diff --git a/.github/workflows/translation_push.yml b/.github/workflows/translation_push.yml new file mode 100644 index 00000000..80b5a5da --- /dev/null +++ b/.github/workflows/translation_push.yml @@ -0,0 +1,23 @@ +name: Crowdin Action + +on: + push: + paths: ['i18n/**'] + branches: [master] + +jobs: + crowdin-upload: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - name: Crowdin push + uses: crowdin/github-action@v1 + with: + upload_sources: true + upload_translations: true + download_translations: false + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 00000000..7673d6b2 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,23 @@ +project_id: 'CROWDIN_PROJECT_ID' +api_token: 'CROWDIN_PERSONAL_TOKEN' +base_path: '.' +base_url: 'https://api.crowdin.com' +preserve_hierarchy: true + +files: + # JSON translation files + - source: /i18n/en/**/* + translation: /i18n/%two_letters_code%/**/%original_file_name% + languages_mapping: + two_letters_code: + en: en + es-ES: es_ES + fr-FR: fr_FR + # Docs Markdown files + - source: /docs/**/* + translation: /i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name% + languages_mapping: + two_letters_code: + en: en + es-ES: es_ES + fr-FR: fr_FR diff --git a/docusaurus.config.js b/docusaurus.config.js index 763a13a7..e2ee9d03 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -27,7 +27,12 @@ const config = { // to replace "en" with "zh-Hans". i18n: { defaultLocale: 'en', - locales: ['en'], + locales: ['en', 'es', 'fr'], + localeConfigs: { + en: { + label: 'English', + }, + }, }, plugins: [ From 084aa618d8fff139ee0e19c1ffc63155c16fa791 Mon Sep 17 00:00:00 2001 From: shafin-deriv Date: Tue, 30 Apr 2024 18:13:40 +0800 Subject: [PATCH 2/2] chore: update token param --- .github/workflows/translation_pull.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/translation_pull.yml b/.github/workflows/translation_pull.yml index e6d967a6..8350be6d 100644 --- a/.github/workflows/translation_pull.yml +++ b/.github/workflows/translation_pull.yml @@ -8,6 +8,7 @@ permissions: write-all jobs: crowdin: runs-on: ubuntu-latest + environment: production steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 @@ -24,6 +25,6 @@ jobs: pull_request_body: 'New Crowdin pull request with translations' pull_request_base_branch_name: 'master' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}