Repository navigation
Add OneLoc localization foundation - #206
Conversation
Add Fluent-to-OneLoc catalog conversion, culture fallback, localized resource generation, pipeline validation, and regression tests. Relates to #118.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall line coverage in commit fbd7cf8 in the Show a line coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
🟡 Changes recommended
The build script currently skips multi-hyphen locale catalogs (e.g., zh-Hans-CN), and the converter unnecessarily rejects duplicate placeholders, both of which can break localization generation/import in valid scenarios.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR establishes the repository-controlled foundation for OneLoc localization by introducing a Fluent ↔ OneLoc JSON converter, a canonical localization catalog, build-time generation of localized Fluent resources, and runtime culture fallback loading in the shell.
Changes:
- Added a
tools/Localizationconverter tool plus a build script to validate/sync the canonical catalog and generateCosmosDBShell/lang/<locale>.ftlfiles. - Updated the shell to embed all
lang/*.ftlresources and to load exact + parent culture resources before falling back to English. - Added regression tests for catalog conversion, numeric select handling, embedded resources, and culture fallback behavior; updated CI pipelines to validate/generate localized resources.
File summaries
| File | Description |
|---|---|
| tools/Localization/Program.cs | Adds a small CLI entrypoint for export/import/verify operations. |
| tools/Localization/FluentCatalogConverter.cs | Implements Fluent AST ↔ JSON catalog conversion, verification, and serialization. |
| tools/Localization/CosmosDBShell.Localization.csproj | Introduces the converter tool project and its Fluent.Net dependency. |
| tools/Localization/build-localized-resources.ps1 | Validates canonical catalog sync and generates localized .ftl files from OneLoc JSON. |
| l10n/LocProject.json | Adds OneLoc project metadata pointing at the canonical JSON catalog. |
| l10n/CosmosDBShell.json | Adds the canonical localization catalog exported from en.ftl. |
| CosmosDBShell/CosmosDBShell.csproj | Embeds all .ftl resources (not only English) into the app. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Util/MessageService.cs | Implements culture fallback enumeration and resource lookup for embedded lang.<culture>.ftl. |
| CosmosDBShell.Tests/MessageServiceCultureTests.cs | Adds tests for culture fallback ordering and English embedded fallback presence. |
| CosmosDBShell.Tests/Localization/FluentCatalogConverterTests.cs | Adds converter regression tests including selects, numeric variants, and round-tripping en.ftl. |
| CosmosDBShell.Tests/CosmosDBShell.Tests.csproj | References the new localization tool project for test access. |
| .pipelines/CosmosDB-Shell-Official.yml | Adds localized-resource generation + preserves localization diagnostics in artifacts. |
| .github/workflows/validate-and-package.yml | Adds localized-resource generation step to GitHub Actions validation. |
| .gitignore | Ignores build-generated localized lang/*.ftl files while keeping en.ftl. |
Review details
- Files reviewed: 12/14 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Use a static Regex instance so Guardian's Roslyn analysis build, which overrides compiler feature flags, does not suppress the generated partial implementation.
There was a problem hiding this comment.
🟡 Changes recommended
The build-localized-resources PowerShell script is not cross-platform due to embedded backslashes in Join-Path inputs, and the converter currently rejects duplicate placeholders that can be valid in real translations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
tools/Localization/FluentCatalogConverter.cs:252
- ImportPattern rejects duplicate placeholders in translations, but some locales legitimately need to repeat the same variable/value more than once (e.g., using {0} twice). Throwing here will break valid translations even though the AST can safely reuse the same placeholder node.
if (!seen.Add(index))
{
throw new InvalidDataException($"Translation '{path}' contains duplicate placeholder '{{{index}}}'.");
}
tools/Localization/build-localized-resources.ps1:27
- The output path uses a Windows-style backslash in an interpolated string ("CosmosDBShell\lang$locale.ftl"), which will not resolve correctly on non-Windows agents. Build it via Join-Path segments so generated locale files land in the expected folder cross-platform.
$output = Join-Path $repoRoot "CosmosDBShell\lang\$locale.ftl"
- Files reviewed: 12/14 changed files
- Comments generated: 1
- Review effort level: Lite
Dispose test readers, allow repeated placeholders, support multi-part locale names, and clarify localization tool usage.
Use platform-neutral paths so localized resource generation works under PowerShell on Windows, Linux, and macOS runners.
There was a problem hiding this comment.
🔵 Needs a closer look
The current English-culture short-circuit in culture fallback conflicts with the stated “exact culture then parent” behavior (e.g., en-US would never be attempted even if present).
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
CosmosDBShell/Azure.Data.Cosmos.Shell.Util/MessageService.cs:59
- GetCultureFallbacks returns an empty list for any English UI culture (e.g. en-US), so the runtime will never attempt to load an exact English culture resource even if one is embedded. This seems inconsistent with the PR description of loading the exact culture + parent chain before falling back to English; an en-US-specific resource would be ignored.
CosmosDBShell.Tests/MessageServiceCultureTests.cs:25 - The GetCultureFallbacks test currently asserts that en-US produces no fallbacks, which matches the current implementation but conflicts with the stated goal of trying the exact culture before falling back to English. If GetCultureFallbacks is updated to include en-US, this test should be adjusted accordingly.
- Files reviewed: 12/14 changed files
- Comments generated: 0 new
- Review effort level: Lite
Try an exact English culture such as en-US before using the neutral English fallback, and update culture fallback coverage.
|
Addressed the two suppressed Copilot findings in 8da7dd4: regional English resources such as en-US are now attempted before neutral English, and the culture fallback test now verifies that behavior. |
There was a problem hiding this comment.
🔵 Needs a closer look
The catalog reader deserializes into a culture-sensitive SortedDictionary, which can make key ordering/comparisons vary by culture and should be changed to StringComparer.Ordinal for canonical stability.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
tools/Localization/FluentCatalogConverter.cs:107
- ReadCatalog deserializes directly into SortedDictionary<string,string>, which uses the default string comparer (culture-sensitive ordering via string.CompareTo). That can make key ordering/comparisons vary by CurrentCulture and can even treat distinct keys as equal in edge cases. Since the catalog is intended to be canonical and stable, prefer deserializing into a Dictionary and then constructing a SortedDictionary with StringComparer.Ordinal.
- Files reviewed: 12/14 changed files
- Comments generated: 0 new
- Review effort level: Lite
Preserve ordinal catalog ordering, narrow expected CLI exception handling, and use non-resetting path joins in tests.
|
Addressed the suppressed canonical-ordering finding in ab243c9: JSON is deserialized into a dictionary and copied into a SortedDictionary with StringComparer.Ordinal. |
There was a problem hiding this comment.
🟡 Changes recommended
The converter’s placeholder parsing can throw an uncaught OverflowException on malformed catalogs, causing the localization tool to crash instead of reporting a clean validation error.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 12/14 changed files
- Comments generated: 1
- Review effort level: Lite
Report malformed oversized catalog placeholders as InvalidDataException instead of allowing integer parsing overflow, with regression coverage.
There was a problem hiding this comment.
🔵 Needs a closer look
The official pipeline’s new “Stage localization diagnostics” step appears to be a no-op as placed (no producer of loc/** is defined before it), so the intended diagnostics preservation likely won’t work as-is.
Review details
Suppressed comments (4)
Previously missed (3) — in code that hasn't changed since the last review.
.pipelines/CosmosDB-Shell-Official.yml:99
- This "Stage localization diagnostics" step currently copies
loc/**from$(Build.ArtifactStagingDirectory), but this YAML doesn’t define any prior task that creates alocfolder under the artifact staging directory. As written (and placed at the very start of the job), it will consistently stage nothing, so localization diagnostics won’t actually make it into the publishedoutartifact.
tools/Localization/build-localized-resources.ps1:12 dotnet rundefaults to Debug configuration; in CI this can cause an extra Debug build of the localization tool before the main solution is built in Release (and it can also diverge from CI build settings). Passing an explicit configuration avoids the redundant build work.
This issue also appears on line 28 of the same file.
tools/Localization/CosmosDBShell.Localization.csproj:9
- This project is executed via
dotnet runin CI (seetools/Localization/build-localized-resources.ps1). SettingSelfContained=truewithUseCurrentRuntimeIdentifier=trueforces RID-specific builds and can download runtime packs unnecessarily, increasing build time and output size for a tool that doesn’t need to be self-contained when run from the SDK.
tools/Localization/build-localized-resources.ps1:28
- This
dotnet runinvocation also defaults to Debug, which can trigger redundant builds in CI and slow down localization generation for each locale. Use an explicit configuration to align with CI builds and reduce extra work.
dotnet run --project $project --no-restore -- import $source $_.FullName $output
- Files reviewed: 12/14 changed files
- Comments generated: 0 new
- Review effort level: Lite
Remove premature diagnostics staging, run localization conversion in Release, and build the converter as an executable only when invoked so test references remain lightweight.
|
Addressed all four suppressed sixth-pass findings in c5a99f8: removed the no-op diagnostics copy and stale loc artifact whitelist; both converter invocations now use Release; and the converter is a library for test references, opting into executable output only for dotnet run, avoiding self-contained RID/runtime-pack overhead. |
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces new build-time generation and pipeline enforcement for localization plus a large canonical catalog, which warrants final human verification of CI/publishing behavior.
Review details
- Files reviewed: 12/14 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces a new localization toolchain plus CI/pipeline integration and a large canonical catalog, which warrants final human verification of end-to-end build/pipeline behavior.
Review details
- Files reviewed: 12/14 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
The official pipeline YAML enables OneLocBuild@3 even though the PR description states that task is still deferred, so the implementation and stated intent need to be reconciled.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 12/14 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces cross-cutting changes to localization tooling, build orchestration, embedded resources, and CI pipelines that warrant a final human validation pass (especially around end-to-end build/package behavior).
Review details
- Files reviewed: 13/15 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
Establish the repository-side localization foundation for OneLoc while keeping Fluent as the source and runtime resource format.
Catalog Synchronization
l10n/CosmosDBShell.jsonfromCosmosDBShell/lang/en.ftl, without rewriting unchanged catalogs.CONTRIBUTING.md.OneLoc Onboarding
The
OneLocBuild@3task remains in the official pipeline as a commented-out block pending OneLoc onboarding. Its dependency feed, authentication, and localization bot/repository permissions must be confirmed before enabling it. Repository-side catalog validation and localized-resource generation remain active.Relates to #118