Skip to content

Add option to generate neutral .xlf file in XliffTasks - #17272

Merged
akoeplinger merged 1 commit into
mainfrom
xlf-neutral-language-files
Aug 6, 2026
Merged

akoeplinger merged 1 commit into
mainfrom
xlf-neutral-language-files

Conversation

@akoeplinger

Copy link
Copy Markdown
Member

Adds a CreateNeutralXlf property that generates the neutral (language-agnostic) .xlf file (e.g. xlf/Strings.xlf next to xlf/Strings.cs.xlf) directly from the source document, alongside the per-language files.

Today eng/common/generate-locproject.ps1 synthesizes this file at build time by copying an arbitrary language's .xlf and stripping the language code from its name. Since the neutral files are now real checked-in sources kept in sync by UpdateXlf, LocProject.json no longer points at dynamically generated content and can be checked in and reviewed, and localization can use OneLoc Native2Native on the .xlf files.

Implementation notes

  • The neutral language (en) is appended to the language list in MSBuild (_XlfLanguages) when CreateNeutralXlf is true, so UpdateXlf/SortXlf handle it through the exact same code path as any other language.
  • GatherXlf, TransformTemplates and EnsureAllResourcesTranslated skip the neutral language, so no en satellite assembly is produced and translation completeness checks are unaffected.
  • A _ValidateXlfLanguages target errors if en is listed in XlfLanguages, since it is reserved as the neutral language (it is never a legitimate entry today).
  • The language list is now recorded in XlfSources.txt, so toggling CreateNeutralXlf (or changing XlfLanguages) correctly invalidates the incremental _UpdateXlf marker. The latter was a pre-existing bug.

Validation

  • XliffTasks unit tests pass.
  • Validated end-to-end against dotnet/runtime: neutral Strings.xlf is generated with source-language="en" target-language="en" and the same trans-unit count as the per-language files, generation is idempotent, exactly the 13 expected satellite culture directories are produced, and EnsureAllResourcesTranslated results are unchanged from baseline.

Add a CreateNeutralXlf property that generates the neutral (language-agnostic)
.xlf file directly from the source document, alongside the per-language files.

This replaces the neutral .xlf that generate-locproject.ps1 synthesizes at
build time by copying an arbitrary language's file and stripping the language
code from its name. Since the neutral files are now real checked-in sources
kept in sync by UpdateXlf, LocProject.json no longer points at dynamically
generated content and can be checked in and reviewed, and localization can use
OneLoc Native2Native (https://aka.ms/OneLocNative2Native) on the .xlf files.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 519d2a22-13c1-4e59-a876-bf421438cd9b
Copilot AI review requested due to automatic review settings August 6, 2026 19:30

@missymessa missymessa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM shipit

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support in Microsoft.DotNet.XliffTasks for generating and maintaining a checked-in neutral (language-agnostic) .xlf alongside per-language .xlf files, enabling localization workflows to consume a stable source-of-truth .xlf rather than build-time synthesized artifacts.

Changes:

  • Introduces a neutral language concept (en) in task code and adjusts .xlf path generation to omit the language suffix for the neutral file.
  • Updates MSBuild targets to optionally append en when CreateNeutralXlf=true, validate that en is not specified in XlfLanguages, and include languages in the incremental marker inputs.
  • Updates tasks that produce translated outputs (satellite assemblies / template transforms / translation completeness checks) to skip the neutral language.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Microsoft.DotNet.XliffTasks/Tasks/XlfTask.cs Adds neutral language constant + helper, and updates .xlf naming to produce a neutral path without a language suffix.
src/Microsoft.DotNet.XliffTasks/Tasks/TransformTemplates.cs Skips the neutral language when producing localized template outputs.
src/Microsoft.DotNet.XliffTasks/Tasks/GatherXlf.cs Skips the neutral language and switches output construction to a list to avoid fixed-size assumptions.
src/Microsoft.DotNet.XliffTasks/Tasks/EnsureAllResourcesTranslated.cs Skips the neutral language so translation completeness checks remain scoped to real translations.
src/Microsoft.DotNet.XliffTasks/README.md Documents CreateNeutralXlf and clarifies that en is not a valid XlfLanguages entry.
src/Microsoft.DotNet.XliffTasks/build/Microsoft.DotNet.XliffTasks.targets Adds CreateNeutralXlf plumbing, validation for en, and improves incremental invalidation by recording languages.
src/Microsoft.DotNet.XliffTasks/build/Microsoft.DotNet.XliffTasks.props Adds the CreateNeutralXlf property with default false and documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@akoeplinger
akoeplinger merged commit b91b69b into main Aug 6, 2026
10 of 13 checks passed
@akoeplinger
akoeplinger deleted the xlf-neutral-language-files branch August 6, 2026 20:48
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Aug 7, 2026
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