From 89866378ef1a3e18c29911cf863940b4603ec766 Mon Sep 17 00:00:00 2001 From: JimmFly Date: Thu, 12 Jan 2023 13:02:32 +0800 Subject: [PATCH 1/6] feat: add i18n keys auto sync --- .github/workflows/languages-sync.yml | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/languages-sync.yml diff --git a/.github/workflows/languages-sync.yml b/.github/workflows/languages-sync.yml new file mode 100644 index 0000000000..1bb8049e66 --- /dev/null +++ b/.github/workflows/languages-sync.yml @@ -0,0 +1,63 @@ +name: Languages Sync + +on: + # push: + # branches: [ "develop", "master" ] + # paths: + # - 'libs/datasource/i18n/**' + # - '.github/workflows/languages-sync.yml' + # pull_request: + # branches: [ "develop", "master" ] + # paths: + # - 'libs/datasource/i18n/**' + # - '.github/workflows/languages-sync.yml' + workflow_dispatch: + +# Cancels all previous workflow runs for pull requests that have not completed. +# See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # The concurrency group contains the workflow name and the branch name for + # pull requests or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + main: + strategy: + matrix: + node-version: [18] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + + - name: Use Node.js ${{ matrix.node-version }} + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Install node modules + run: pnpm install + + - name: Check Language Key + if: github.ref != 'refs/heads/master' + working-directory: ./packages/i18n + run: pnpm run sync-languages:check + env: + TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} + + - name: Sync Languages + if: github.ref == 'refs/heads/master' + working-directory: ./packages/i18n + run: pnpm run sync-languages + env: + TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} From 2867cb07c5bf5e52a5e76a2b8bf053c790439781 Mon Sep 17 00:00:00 2001 From: JimmFly Date: Thu, 12 Jan 2023 14:16:49 +0800 Subject: [PATCH 2/6] feat: add push and pr events --- .github/workflows/languages-sync.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/languages-sync.yml b/.github/workflows/languages-sync.yml index 1bb8049e66..3cacc35749 100644 --- a/.github/workflows/languages-sync.yml +++ b/.github/workflows/languages-sync.yml @@ -1,16 +1,16 @@ name: Languages Sync on: - # push: - # branches: [ "develop", "master" ] - # paths: - # - 'libs/datasource/i18n/**' - # - '.github/workflows/languages-sync.yml' - # pull_request: - # branches: [ "develop", "master" ] - # paths: - # - 'libs/datasource/i18n/**' - # - '.github/workflows/languages-sync.yml' + push: + branches: ['master'] + paths: + - 'packages/i18n/**' + - '.github/workflows/languages-sync.yml' + pull_request: + branches: ['master'] + paths: + - 'packages/i18n/**' + - '.github/workflows/languages-sync.yml' workflow_dispatch: # Cancels all previous workflow runs for pull requests that have not completed. From b2f44f9fab9c720adc7119ae54b271d63f3a264b Mon Sep 17 00:00:00 2001 From: JimmFly Date: Thu, 12 Jan 2023 14:29:18 +0800 Subject: [PATCH 3/6] chore: update readme --- packages/i18n/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/i18n/README.md b/packages/i18n/README.md index f8ad64372a..ec443f6fc8 100644 --- a/packages/i18n/README.md +++ b/packages/i18n/README.md @@ -36,6 +36,12 @@ const App = () => { }; ``` +## How the i18n workflow works? + +- When the `src/resources/en.json`(base language) updated and merged to the develop branch, will trigger the `languages-sync` action. +- The `languages-sync` action will check the base language and add missing translations to the Tolgee platform. +- This way, partners from the community can update the translations. + ## How to sync translations manually - Set token as environment variable @@ -45,7 +51,8 @@ export TOLGEE_API_KEY=tgpak_XXXXXXX ``` - Run the `sync-languages:check` to check all languages -- Run the `sync-languages` script to add new keys to the tolgee platform +- Run the `sync-languages` script to add new keys to the Tolgee platform +- Run the `download-resources` script to download the latest full-translation translation resources from the Tolgee platform ## References From b855f71ebfcfc990cf90d118d689c3429a831658 Mon Sep 17 00:00:00 2001 From: JimmFly Date: Thu, 12 Jan 2023 14:32:45 +0800 Subject: [PATCH 4/6] test: test ci --- packages/i18n/src/resources/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/i18n/src/resources/en.json b/packages/i18n/src/resources/en.json index 2831a8aafe..4dd82e101e 100644 --- a/packages/i18n/src/resources/en.json +++ b/packages/i18n/src/resources/en.json @@ -141,5 +141,6 @@ "Sign in": "Sign in to AFFiNE Cloud", "Sync Description": "{{workspaceName}} is a Local Workspace. All data is stored on the current device. You can enable AFFiNE Cloud for this workspace to keep data in sync with the cloud.", "Sync Description2": "<1>{{workspaceName}} is a Cloud Workspace. All data will be synchronised and saved to AFFiNE Cloud.", - "Delete Workspace Description": "Deleting (<1>{{workspace}}) cannot be undone, please proceed with caution. All contents will be lost." + "Delete Workspace Description": "Deleting (<1>{{workspace}}) cannot be undone, please proceed with caution. All contents will be lost", + "test case": "test case" } From 082894d08cf24902eefc36958fec1f7738bd4dff Mon Sep 17 00:00:00 2001 From: JimmFly Date: Thu, 12 Jan 2023 14:52:07 +0800 Subject: [PATCH 5/6] chore: restore en.json --- packages/i18n/src/resources/en.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/i18n/src/resources/en.json b/packages/i18n/src/resources/en.json index 4dd82e101e..2831a8aafe 100644 --- a/packages/i18n/src/resources/en.json +++ b/packages/i18n/src/resources/en.json @@ -141,6 +141,5 @@ "Sign in": "Sign in to AFFiNE Cloud", "Sync Description": "{{workspaceName}} is a Local Workspace. All data is stored on the current device. You can enable AFFiNE Cloud for this workspace to keep data in sync with the cloud.", "Sync Description2": "<1>{{workspaceName}} is a Cloud Workspace. All data will be synchronised and saved to AFFiNE Cloud.", - "Delete Workspace Description": "Deleting (<1>{{workspace}}) cannot be undone, please proceed with caution. All contents will be lost", - "test case": "test case" + "Delete Workspace Description": "Deleting (<1>{{workspace}}) cannot be undone, please proceed with caution. All contents will be lost." } From 3d6361ba3d566f84b76fffc74dcd866dcf5c3446 Mon Sep 17 00:00:00 2001 From: JimmFly Date: Thu, 12 Jan 2023 15:02:23 +0800 Subject: [PATCH 6/6] feat: add en.json codeOwners --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f80d334591..98be545ece 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,3 @@ **/project.json @darkskygit **/pnpm-lock.yaml @darkskygit +**/en.json @JimmFly \ No newline at end of file