Repository navigation
ci(website): open translation PRs automatically #21032
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
Changes from all commits
93ad770
a736369
67c001e
6131078
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,19 +2,30 @@ | |||||||||||||||||||||||||||||||||||||||
| name: 'i18n: Update Website' | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||||
| branches: [main] | ||||||||||||||||||||||||||||||||||||||||
| paths: | ||||||||||||||||||||||||||||||||||||||||
| - 'apps/website/src/locales/en/*.json' | ||||||||||||||||||||||||||||||||||||||||
| - 'apps/website/src/config/locales.ts' | ||||||||||||||||||||||||||||||||||||||||
| - 'apps/website/src/config/translation.ts' | ||||||||||||||||||||||||||||||||||||||||
| - 'scripts/i18n/config.ts' | ||||||||||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||||||||||
| - cron: '17 10 * * *' | ||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||
| pull-requests: read | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||||||||||||||||
| group: i18n-update-website-${{ github.ref }} | ||||||||||||||||||||||||||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||
| update-locales: | ||||||||||||||||||||||||||||||||||||||||
| if: github.ref_type == 'branch' | ||||||||||||||||||||||||||||||||||||||||
| if: github.repository == 'Comfy-Org/ComfyUI_frontend' && github.ref_type == 'branch' | ||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||
| timeout-minutes: 30 | ||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v7 | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -27,7 +38,31 @@ jobs: | |||||||||||||||||||||||||||||||||||||||
| - name: Setup ComfyUI Frontend | ||||||||||||||||||||||||||||||||||||||||
| uses: ./.github/actions/setup-frontend | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Build on the open translation PR | ||||||||||||||||||||||||||||||||||||||||
| id: base | ||||||||||||||||||||||||||||||||||||||||
| if: github.ref_name == 'main' | ||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||||||||||||||||||||||||||||||||
| TRANSLATION_BRANCH: i18n/website-locales | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||
| echo "main_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||
| open_pr=$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&head=$GITHUB_REPOSITORY_OWNER:$TRANSLATION_BRANCH" \ | ||||||||||||||||||||||||||||||||||||||||
| --jq '.[0].html_url // empty') | ||||||||||||||||||||||||||||||||||||||||
| echo "open_pr=$open_pr" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||
| if [ -z "$open_pr" ]; then exit 0; fi | ||||||||||||||||||||||||||||||||||||||||
| git fetch --no-tags origin "refs/heads/$TRANSLATION_BRANCH" | ||||||||||||||||||||||||||||||||||||||||
| echo "branch_sha=$(git rev-parse FETCH_HEAD)" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||
| if git -c user.name=github-actions -c user.email=github-actions@github.com \ | ||||||||||||||||||||||||||||||||||||||||
| merge --no-edit FETCH_HEAD; then | ||||||||||||||||||||||||||||||||||||||||
| echo "merged=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||
| git merge --abort | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (P3): Merging
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Update translations | ||||||||||||||||||||||||||||||||||||||||
| id: translate | ||||||||||||||||||||||||||||||||||||||||
| continue-on-error: true | ||||||||||||||||||||||||||||||||||||||||
| run: pnpm --filter @comfyorg/website locale | ||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -39,16 +74,54 @@ jobs: | |||||||||||||||||||||||||||||||||||||||
| if git diff --cached --quiet; then exit 0; fi | ||||||||||||||||||||||||||||||||||||||||
| ./scripts/cicd/check-json.sh | ||||||||||||||||||||||||||||||||||||||||
| git -c user.name=github-actions -c user.email=github-actions@github.com \ | ||||||||||||||||||||||||||||||||||||||||
| commit -m 'Update website locales' | ||||||||||||||||||||||||||||||||||||||||
| commit -m 'fix(website): update locale catalogs' | ||||||||||||||||||||||||||||||||||||||||
| echo "committed=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Only this step sees the push token: the steps above run scripts from | ||||||||||||||||||||||||||||||||||||||||
| # the dispatched branch | ||||||||||||||||||||||||||||||||||||||||
| - name: Push updated locales | ||||||||||||||||||||||||||||||||||||||||
| if: steps.commit.outputs.committed == 'true' | ||||||||||||||||||||||||||||||||||||||||
| - name: Publish updated locales | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 question: commit
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kept the shell. After 6131078 the step merges main into the open branch and pushes with a lease, which the action's regenerate-from-base model does not do. The fork-safe lookup and the stale-PR close it gave for free are now handled here. |
||||||||||||||||||||||||||||||||||||||||
| if: steps.commit.outputs.committed == 'true' || github.ref_name == 'main' | ||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||
| TARGET_BRANCH: ${{ github.ref_name }} | ||||||||||||||||||||||||||||||||||||||||
| PR_GH_TOKEN: ${{ secrets.PR_GH_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ secrets.PR_GH_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||
| SOURCE_BRANCH: ${{ github.ref_name }} | ||||||||||||||||||||||||||||||||||||||||
| TRANSLATION_BRANCH: i18n/website-locales | ||||||||||||||||||||||||||||||||||||||||
| COMMITTED: ${{ steps.commit.outputs.committed }} | ||||||||||||||||||||||||||||||||||||||||
| MAIN_SHA: ${{ steps.base.outputs.main_sha }} | ||||||||||||||||||||||||||||||||||||||||
| OPEN_PR: ${{ steps.base.outputs.open_pr }} | ||||||||||||||||||||||||||||||||||||||||
| BRANCH_SHA: ${{ steps.base.outputs.branch_sha }} | ||||||||||||||||||||||||||||||||||||||||
| MERGED: ${{ steps.base.outputs.merged }} | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Companion to the comment on lines 99-107. The publish step needs the translate outcome to avoid closing the PR after a failed run, and
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||
| remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||||||||||||||||||||||||||||||||||||||||
| if [ "$SOURCE_BRANCH" != main ]; then | ||||||||||||||||||||||||||||||||||||||||
| git push "$remote" "HEAD:refs/heads/$SOURCE_BRANCH" | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| if git diff --quiet "$MAIN_SHA" HEAD; then | ||||||||||||||||||||||||||||||||||||||||
| if [ -n "$OPEN_PR" ]; then | ||||||||||||||||||||||||||||||||||||||||
| gh pr close "$OPEN_PR" --delete-branch --comment 'Main already has every translation on this branch.' | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| if [ "$COMMITTED" != true ] && [ "$MERGED" = true ]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "No new translations for $OPEN_PR" | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: A failed translation run can close a valid translation PR and delete its branch. When the merge on line 56 conflicts, HEAD stays at main. If The suggestion gates the close on a successful translate step. It also drops the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| lease=--force | ||||||||||||||||||||||||||||||||||||||||
| if [ -n "$BRANCH_SHA" ]; then | ||||||||||||||||||||||||||||||||||||||||
| lease="--force-with-lease=refs/heads/$TRANSLATION_BRANCH:$BRANCH_SHA" | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| git push "$lease" "$remote" "HEAD:refs/heads/$TRANSLATION_BRANCH" | ||||||||||||||||||||||||||||||||||||||||
| if [ -n "$OPEN_PR" ]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Updated $OPEN_PR" | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| body=$(printf '## Summary\n\nTranslations of new or changed English website copy, generated by [this workflow run](%s).\n\nLater runs merge main into this branch and translate only what changed, so translations edited here are kept.\n' "$RUN_URL") | ||||||||||||||||||||||||||||||||||||||||
| gh pr create --repo "$GITHUB_REPOSITORY" --base main --head "$TRANSLATION_BRANCH" \ | ||||||||||||||||||||||||||||||||||||||||
| --title 'fix(website): update locale catalogs' --body "$body" \ | ||||||||||||||||||||||||||||||||||||||||
| --label area:i18n --assignee benceruleanlu | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This is the only hard-coded personal handle in
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the assignee: these PRs should land in my queue, and there is no CODEOWNERS entry for the website locales to route them instead. |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Fail if translation did not finish | ||||||||||||||||||||||||||||||||||||||||
| if: steps.translate.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| git push "https://x-access-token:${PR_GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \ | ||||||||||||||||||||||||||||||||||||||||
| "HEAD:refs/heads/$TARGET_BRANCH" | ||||||||||||||||||||||||||||||||||||||||
| echo "::error::Website translation did not finish; the Update translations step lists what failed." | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+123
to
+126
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (P3): Since strings with no valid translation make
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,8 +36,11 @@ file wins. These root rules do not apply here: | |||||||||||||||||||
| vue-i18n message syntax), not in the app's root `src/locales/`. Read it with | ||||||||||||||||||||
| the request-bound `Astro.locals.t` in Astro or `translationsFor(locale).t` in | ||||||||||||||||||||
| Vue and TypeScript; never fill a placeholder with `.replace`. Write a literal | ||||||||||||||||||||
| `@`, `|`, `{` or `}` as `{'@'}`, `{'|'}`, `{'{'}` or `{'}'}`. Add `en` and | ||||||||||||||||||||
| `zh-CN` values for every new string. See the README's Localization section. | ||||||||||||||||||||
| `@`, `|`, `{` or `}` as `{'@'}`, `{'|'}`, `{'{'}` or `{'}'}`. Write new and | ||||||||||||||||||||
| changed copy in `en/main.json` only. Do not edit another locale's file except | ||||||||||||||||||||
| for the excluded legal namespaces in `src/config/translation.ts`: a workflow | ||||||||||||||||||||
| translates eligible English changes on main into a PR, and missing strings | ||||||||||||||||||||
| render in English until it merges. See the README's Localization section. | ||||||||||||||||||||
|
Comment on lines
+39
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Same contradiction as the comment on
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied in 6131078. |
||||||||||||||||||||
| - The dev server is `pnpm --filter @comfyorg/website dev` on | ||||||||||||||||||||
| `http://localhost:4321`, not `pnpm dev` on 5173. The root | ||||||||||||||||||||
| `/verify-visually` command points at the wrong server for this site. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,16 +53,15 @@ as the application's `src/locales/` at the repository root: | |||||||||||||||||||||||
| API. Astro middleware binds `Astro.locals.t` to the request locale. In Vue and | ||||||||||||||||||||||||
| TypeScript, bind once with `translationsFor(locale).t`; each locale has its own | ||||||||||||||||||||||||
| composer because the site renders locales concurrently. Missing messages fall | ||||||||||||||||||||||||
| back to English. The catalog test compiles every message and checks that each | ||||||||||||||||||||||||
| eligible English message has Chinese copy. | ||||||||||||||||||||||||
| back to English. The catalog test compiles every message in every locale. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| `main.json` is the catalog for each locale. Keep feature copy grouped under a | ||||||||||||||||||||||||
| nested feature key. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Add new English copy to the English catalog; translated copy lives in the | ||||||||||||||||||||||||
| matching file under each locale. Every eligible English message requires a | ||||||||||||||||||||||||
| Chinese entry. Excluded namespaces use English fallback when no translation | ||||||||||||||||||||||||
| exists. The catalog tests enforce this distinction. | ||||||||||||||||||||||||
| Write new and changed copy in the English catalog only. Do not add or edit | ||||||||||||||||||||||||
| eligible copy in other locales by hand: the generation workflow below | ||||||||||||||||||||||||
| translates it after it merges, and until then those strings render in English. | ||||||||||||||||||||||||
| People maintain the excluded namespaces listed below. | ||||||||||||||||||||||||
| Catalog files use two-space JSON indentation and a final newline. Legal and | ||||||||||||||||||||||||
| content pages render their sections in the order they appear in the catalog, so | ||||||||||||||||||||||||
| keep `en/main.json` in document order and never sort its keys. | ||||||||||||||||||||||||
|
|
@@ -100,6 +99,15 @@ have no `/ja/` route yet. Generation never enables routes or indexing. | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Generating translations | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| The `i18n: Update Website` workflow runs when English catalogs or translation | ||||||||||||||||||||||||
| config change on main, and daily. It opens or updates one | ||||||||||||||||||||||||
| `fix(website): update locale catalogs` PR from the `i18n/website-locales` | ||||||||||||||||||||||||
| branch. While that PR is open, each run merges main into the branch and | ||||||||||||||||||||||||
| translates only what changed, so translations edited on the branch are kept. | ||||||||||||||||||||||||
| When the branch conflicts with main, the run regenerates it from main instead. | ||||||||||||||||||||||||
| Running the workflow by hand on another branch commits the translations to that | ||||||||||||||||||||||||
| branch instead. | ||||||||||||||||||||||||
|
Comment on lines
+105
to
+109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Two gaps against the workflow. "Translations edited on the branch are kept" is followed by the conflict case without saying that regenerating from main force-pushes over those edits. In the simulation, the hand edit on the branch is gone after the forced update. Conflicts are plausible here: main still edits
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Inside this package, run `pnpm locale:check` for an offline preflight, or | ||||||||||||||||||||||||
| `pnpm locale` with `OPENAI_API_KEY` to translate eligible missing or changed | ||||||||||||||||||||||||
| copy. Both scripts call the shared CLI in `scripts/i18n/update-locales.ts` with | ||||||||||||||||||||||||
|
|
@@ -114,8 +122,11 @@ of the English last generated. Its `knownViolations` field lists accepted | |||||||||||||||||||||||
| protected-token violations as JSON-encoded key paths, such as | ||||||||||||||||||||||||
| `["cloud","reason","1","title"]`. Use a clone with full history: if the recorded | ||||||||||||||||||||||||
| blob is missing, `locale:check` warns and skips change detection and token | ||||||||||||||||||||||||
| validation for that file, and `pnpm locale` fails. When translation of an entry file fails, | ||||||||||||||||||||||||
| its English, locale catalogs and manifest entry keep their previous contents. | ||||||||||||||||||||||||
| validation for that file, and `pnpm locale` fails. When a translation request | ||||||||||||||||||||||||
| for an entry file throws, such as an HTTP or network error, its English, locale | ||||||||||||||||||||||||
| catalogs and manifest entry keep their previous contents. Strings the provider | ||||||||||||||||||||||||
| defers or the model keeps getting wrong are left out and retried on the next | ||||||||||||||||||||||||
| run. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Commit the generated English catalog, locale catalogs and manifest together. If | ||||||||||||||||||||||||
| you edit any of them after generation, run `pnpm locale` again before | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,24 +53,39 @@ describe('translateLocaleItems', () => { | |
| ) | ||
| ) | ||
| } | ||
| const translations = await translateLocaleItems( | ||
| const { translated } = await translateLocaleItems( | ||
| locale, | ||
| items, | ||
| flaky, | ||
| translationConfig | ||
| ) | ||
| expect(translations.get('1')).toBe('Bonjour {name}') | ||
| expect(translated.get('1')).toBe('Bonjour {name}') | ||
| expect(calls).toBe(2) | ||
| }) | ||
|
|
||
| it('fails after exhausting rounds when tokens stay corrupted', async () => { | ||
| const corrupting: TranslateBatch = (_batchLocale, batch) => | ||
| it('keeps passing translations and reports items still corrupted after the last round', async () => { | ||
| const corruptingGreeting: TranslateBatch = (_batchLocale, batch) => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value Declare the named translator fixture as a function. Replace the 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| Promise.resolve( | ||
| Object.fromEntries(batch.map((item) => [item.id, 'Bonjour name'])) | ||
| Object.fromEntries( | ||
| batch.map((item) => [ | ||
| item.id, | ||
| item.id === '1' ? 'Bonjour name' : 'Titre' | ||
| ]) | ||
| ) | ||
| ) | ||
| await expect( | ||
| translateLocaleItems(locale, items, corrupting, translationConfig) | ||
| ).rejects.toThrow(/failed for 1 strings/) | ||
| const { translated, untranslated } = await translateLocaleItems( | ||
| locale, | ||
| [ | ||
| ...items, | ||
| { id: '2', context: 'main.json: title', source: 'Title', preserve: [] } | ||
| ], | ||
| corruptingGreeting, | ||
| translationConfig | ||
| ) | ||
| expect(translated).toEqual(new Map([['2', 'Titre']])) | ||
| expect(untranslated.map(({ context }) => context)).toEqual([ | ||
| 'main.json: greeting' | ||
| ]) | ||
| }) | ||
|
|
||
| it('retries empty translations', async () => { | ||
|
|
@@ -83,13 +98,13 @@ describe('translateLocaleItems', () => { | |
| ) | ||
| ) | ||
| } | ||
| const translations = await translateLocaleItems( | ||
| const { translated } = await translateLocaleItems( | ||
| locale, | ||
| items, | ||
| blankFirst, | ||
| translationConfig | ||
| ) | ||
| expect(translations.get('1')).toBe('Bonjour {name}') | ||
| expect(translated.get('1')).toBe('Bonjour {name}') | ||
| expect(calls).toBe(2) | ||
| }) | ||
|
|
||
|
|
@@ -111,11 +126,11 @@ describe('translateLocaleItems', () => { | |
| inFlight-- | ||
| return Object.fromEntries(batch.map((item) => [item.id, `t${item.id}`])) | ||
| } | ||
| const translations = await translateLocaleItems(locale, sixItems, gated, { | ||
| const { translated } = await translateLocaleItems(locale, sixItems, gated, { | ||
| ...translationConfig, | ||
| requestConcurrency: 2 | ||
| }) | ||
| expect(translations.size).toBe(6) | ||
| expect(translated.size).toBe(6) | ||
| expect(maxInFlight).toBe(2) | ||
| }) | ||
|
|
||
|
|
@@ -134,13 +149,13 @@ describe('translateLocaleItems', () => { | |
| let call = 0 | ||
| const crossTalking: TranslateBatch = () => | ||
| Promise.resolve(responses[call++] ?? {}) | ||
| const translations = await translateLocaleItems( | ||
| const { translated } = await translateLocaleItems( | ||
| locale, | ||
| threeItems, | ||
| crossTalking, | ||
| translationConfig | ||
| ) | ||
| expect(translations.get('3')).toBe('ok3') | ||
| expect(translated.get('3')).toBe('ok3') | ||
| }) | ||
|
|
||
| it('sends a retry note naming the violation on later rounds', async () => { | ||
|
|
@@ -193,7 +208,7 @@ describe('translateLocaleItems', () => { | |
| ) | ||
| } | ||
|
|
||
| const translations = await translateLocaleItems( | ||
| const { translated } = await translateLocaleItems( | ||
| locale, | ||
| [docsLink], | ||
| correctsOnRetry, | ||
|
|
@@ -206,7 +221,7 @@ describe('translateLocaleItems', () => { | |
| } | ||
| ) | ||
|
|
||
| expect(translations).toEqual(new Map([['1', accepted]])) | ||
| expect(translated).toEqual(new Map([['1', accepted]])) | ||
| expect(requests).toEqual([[docsLink], [{ ...docsLink, retryNote }]]) | ||
| } | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The PR description and README say the push route runs when "translation config" changes, but
scripts/i18n/config.tsholds the website target's model, rounds and batch limits (translationTargets.website) and is not in this list. A change there waits for the daily run.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 6131078.