Skip to content

cms-admin: Resolve the translation language via useContentLanguage - #6361

Open
VPS-Obi wants to merge 1 commit into
mainfrom
claude/bold-allen-ltgdda
Open

VPS-Obi wants to merge 1 commit into
mainfrom
claude/bold-allen-ltgdda

Conversation

@VPS-Obi

@VPS-Obi VPS-Obi commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

AzureAiTranslatorProvider and useTranslatePagesAction read the content language straight off the content scope — targetLanguage: scope.language for the Azure queries, transformToSlug(translatedName, scope.language) for the translated page name. That only works in projects whose content scope happens to have a language dimension. Everywhere else the translator is asked to translate into undefined, and translated page names are slugified without a locale, so a German name becomes uber-uns instead of ueber-uns. ContentScope is declared with an index signature, so reading a dimension that doesn't exist type-checks and nothing ever failed.

Both now resolve the language through useContentLanguage, which goes through the contentLanguage config projects already pass to DextinityConfigProvider:

const { scope } = useContentScope();
const language = useContentLanguage({ scope });

const translatedSlug = transformToSlug(translatedName, language);

createEditPageNode already slugified this way, so the two slug paths agree again.

Both flows get a regression test using a scope without a language dimension: AzureAiTranslatorProvider.test.tsx asserts the targetLanguage sent for the single and the batch query, and useTranslatePagesAction.test.tsx asserts that the translated name is slugified with the resolved locale (Über unsueber-uns, where slugify without a locale gives uber-uns). Reverting either fix makes the corresponding tests fail.

Session: https://claude.ai/code/session_01WMDmoPW9RMKuoikmbr7MaP

@VPS-Obi VPS-Obi self-assigned this Sep 14, 2026
@nsams

nsams commented Sep 14, 2026

Copy link
Copy Markdown
Member

@greptileai review

@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown

Greptile Summary

Updates translation flows to resolve their locale through the configured content-language resolver instead of assuming the content scope has a language dimension.

  • Uses the resolved language for Azure single and batch translation requests.
  • Uses the resolved language for locale-sensitive translated page slugs.
  • Adds regression coverage for scopes without a language dimension.
  • Adds patch changesets for both corrected behaviors.
Confidence Score: 5/5

The PR appears safe to merge, with the prior regression-coverage concern resolved and no outstanding correctness or repository-rule violations.

The new tests cover locale-sensitive page slug generation and both Azure translation paths for scopes without a language dimension. The cross-module import concern was correctly disputed and subsequently conceded because this package does not provide the suggested alias and consistently uses parent-relative imports.

Important Files Changed
Filename Overview
packages/admin/cms-admin/src/pages/pageTree/useTranslatePagesAction.tsx Resolves the content language through useContentLanguage before generating translated page slugs.
packages/admin/cms-admin/src/pages/pageTree/useTranslatePagesAction.test.tsx Verifies locale-sensitive slug generation when the scope lacks a language dimension.
packages/admin/cms-admin/src/translation/AzureAiTranslatorProvider.tsx Sends the configured content language to both Azure translation query paths.
packages/admin/cms-admin/src/translation/AzureAiTranslatorProvider.test.tsx Covers target-language resolution for single and batch translations.

Reviews (4): Last reviewed commit: "cms-admin: Resolve the translation langu..." | Re-trigger Greptile

Comment thread packages/admin/cms-admin/src/pages/pageTree/PageActions.test.tsx
@VPS-Obi
VPS-Obi force-pushed the claude/bold-allen-ltgdda branch from 6115e00 to 3549d56 Compare September 15, 2026 12:25
The Azure translator provider and the page tree translate action both read
the language from scope.language, which only exists in projects whose
content scope contains a language dimension. Resolve it through the
contentLanguage config instead, consistent with createEditPageNode.

Cover both flows with tests that use a scope without a language dimension,
so the mistake cannot come back unnoticed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WMDmoPW9RMKuoikmbr7MaP
@VPS-Obi
VPS-Obi force-pushed the claude/bold-allen-ltgdda branch from 3549d56 to adccc10 Compare September 16, 2026 06:53
@VPS-Obi VPS-Obi changed the title Use useContentLanguage for translation language resolution cms-admin: Resolve the translation language via useContentLanguage Sep 16, 2026
@VPS-Obi
VPS-Obi marked this pull request as ready for review September 16, 2026 07:00
@VPS-Obi

VPS-Obi commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai review

@VPS-Obi
VPS-Obi requested a review from VPS-thodax September 16, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants