From 7f4b5795bf6f1d3c4df2c99eeec0ee4452ee5acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Tue, 18 Feb 2025 21:21:32 +0100 Subject: [PATCH] Stop showing lines on translation files (#10313) --- .github/workflows/i18n-pull.yaml | 2 +- .github/workflows/i18n-push.yaml | 35 +++++++++++++++++-------- packages/twenty-emails/lingui.config.js | 2 ++ packages/twenty-front/lingui.config.ts | 2 ++ packages/twenty-server/lingui.config.js | 2 ++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/i18n-pull.yaml b/.github/workflows/i18n-pull.yaml index 763d21885..25fb0aa4c 100644 --- a/.github/workflows/i18n-pull.yaml +++ b/.github/workflows/i18n-pull.yaml @@ -76,7 +76,7 @@ jobs: download_translations: true export_only_approved: false localization_branch_name: i18n - commit_message: 'i18n - translations' + commit_message: 'i18n - pull translations' pull_request_title: 'i18n - translations' base_url: 'https://twenty.api.crowdin.com' auto_approve_imported: false diff --git a/.github/workflows/i18n-push.yaml b/.github/workflows/i18n-push.yaml index a99ab0182..b65438f4b 100644 --- a/.github/workflows/i18n-push.yaml +++ b/.github/workflows/i18n-push.yaml @@ -40,14 +40,8 @@ jobs: npx nx run twenty-emails:lingui:extract npx nx run twenty-front:lingui:extract - - name: Compile translations - run: | - npx nx run twenty-server:lingui:compile - npx nx run twenty-emails:lingui:compile - npx nx run twenty-front:lingui:compile - - - name: Check and commit any files created - id: check_changes + - name: Check and commit extracted files + id: check_extract_changes run: | git config --global user.name 'github-actions' git config --global user.email 'github-actions@twenty.com' @@ -59,12 +53,31 @@ jobs: echo "changes_detected=false" >> $GITHUB_OUTPUT fi + - name: Compile translations + run: | + npx nx run twenty-server:lingui:compile + npx nx run twenty-emails:lingui:compile + npx nx run twenty-front:lingui:compile + + - name: Check and commit compiled files + id: check_compile_changes + run: | + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@twenty.com' + git add . + if ! git diff --staged --quiet --exit-code; then + git commit -m "chore: compile translations" + echo "changes_detected=true" >> $GITHUB_OUTPUT + else + echo "changes_detected=false" >> $GITHUB_OUTPUT + fi + - name: Push changes and create remote branch if needed - if: steps.check_changes.outputs.changes_detected == 'true' + if: steps.check_extract_changes.outputs.changes_detected == 'true' || steps.check_compile_changes.outputs.changes_detected == 'true' run: git push origin HEAD:i18n - name: Upload missing translations - if: steps.check_changes.outputs.changes_detected == 'true' + if: steps.check_extract_changes.outputs.changes_detected == 'true' uses: crowdin/github-action@v2 with: upload_sources: true @@ -80,7 +93,7 @@ jobs: CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} - name: Create a pull request - if: steps.check_changes.outputs.changes_detected == 'true' + if: steps.check_extract_changes.outputs.changes_detected == 'true' || steps.check_compile_changes.outputs.changes_detected == 'true' run: gh pr create -B main -H i18n --title 'i18n - translations' --body 'Created by Github action' || true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/packages/twenty-emails/lingui.config.js b/packages/twenty-emails/lingui.config.js index ec41a75d7..bf8aa5793 100644 --- a/packages/twenty-emails/lingui.config.js +++ b/packages/twenty-emails/lingui.config.js @@ -1,4 +1,5 @@ import { defineConfig } from '@lingui/cli'; +import { formatter } from '@lingui/format-po'; import { APP_LOCALES } from 'twenty-shared'; export default defineConfig({ @@ -19,4 +20,5 @@ export default defineConfig({ ], catalogsMergePath: '/src/locales/generated/{locale}', compileNamespace: 'ts', + format: formatter({ lineNumbers: false }), }); diff --git a/packages/twenty-front/lingui.config.ts b/packages/twenty-front/lingui.config.ts index 6b31ed6ee..e39740889 100644 --- a/packages/twenty-front/lingui.config.ts +++ b/packages/twenty-front/lingui.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from '@lingui/cli'; +import { formatter } from '@lingui/format-po'; import { APP_LOCALES } from 'twenty-shared'; export default defineConfig({ @@ -16,4 +17,5 @@ export default defineConfig({ ], catalogsMergePath: '/src/locales/generated/{locale}', compileNamespace: 'ts', + format: formatter({ lineNumbers: false }), }); diff --git a/packages/twenty-server/lingui.config.js b/packages/twenty-server/lingui.config.js index 5bbfd1bc1..7dda41746 100644 --- a/packages/twenty-server/lingui.config.js +++ b/packages/twenty-server/lingui.config.js @@ -1,4 +1,5 @@ import { defineConfig } from '@lingui/cli'; +import { formatter } from '@lingui/format-po'; import { APP_LOCALES } from 'twenty-shared'; export default defineConfig({ @@ -20,4 +21,5 @@ export default defineConfig({ catalogsMergePath: '/src/engine/core-modules/i18n/locales/generated/{locale}', compileNamespace: 'ts', + format: formatter({ lineNumbers: false }), });