Repository navigation
Add option to generate neutral .xlf file in XliffTasks - #17272
Merged
Merged
Conversation
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
akoeplinger
enabled auto-merge (squash)
August 6, 2026 19:42
Contributor
There was a problem hiding this comment.
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.xlfpath generation to omit the language suffix for the neutral file. - Updates MSBuild targets to optionally append
enwhenCreateNeutralXlf=true, validate thatenis not specified inXlfLanguages, 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds a
CreateNeutralXlfproperty that generates the neutral (language-agnostic).xlffile (e.g.xlf/Strings.xlfnext toxlf/Strings.cs.xlf) directly from the source document, alongside the per-language files.Today
eng/common/generate-locproject.ps1synthesizes this file at build time by copying an arbitrary language's.xlfand stripping the language code from its name. Since the neutral files are now real checked-in sources kept in sync byUpdateXlf,LocProject.jsonno longer points at dynamically generated content and can be checked in and reviewed, and localization can use OneLoc Native2Native on the.xlffiles.Implementation notes
en) is appended to the language list in MSBuild (_XlfLanguages) whenCreateNeutralXlfistrue, soUpdateXlf/SortXlfhandle it through the exact same code path as any other language.GatherXlf,TransformTemplatesandEnsureAllResourcesTranslatedskip the neutral language, so noensatellite assembly is produced and translation completeness checks are unaffected._ValidateXlfLanguagestarget errors ifenis listed inXlfLanguages, since it is reserved as the neutral language (it is never a legitimate entry today).XlfSources.txt, so togglingCreateNeutralXlf(or changingXlfLanguages) correctly invalidates the incremental_UpdateXlfmarker. The latter was a pre-existing bug.Validation
Strings.xlfis generated withsource-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, andEnsureAllResourcesTranslatedresults are unchanged from baseline.