Skip to content

[iOS] Fix resource language detection when project path contains OS - #23389

Merged
MartinZikmund merged 4 commits into
masterfrom
copilot/fix-resource-localization-ios
Aug 4, 2026
Merged

MartinZikmund merged 4 commits into
masterfrom
copilot/fix-resource-localization-ios

Conversation

Copilot AI commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

closes #4657, closes #3157

PR Type:

🐞 Bugfix

What changed? 🚀

Localization resource generation for iOS could mis-detect language from absolute filesystem segments (e.g., .../OS/...) and emit OS.lproj instead of real locale folders. This updates resource qualifier parsing to use MSBuild-relative TargetPath when available, so locale extraction is based on project item path, not machine path.

  • Resource generation fix

    • ResourcesGenerationTask_v0 now parses ResourceCandidate from TargetPath (fallback: ItemSpec), preventing parent directory names from being treated as language qualifiers.
  • Regression coverage

    • Added a focused unit test in Given_ResourceCandidate for absolute full path + relative target path parsing to validate correct logical path and language extraction.
var relativePath = resource.GetMetadata("TargetPath") is { Length: > 0 } targetPath
	? targetPath
	: resource.ItemSpec;
var resourceCandidate = ResourceCandidate.Parse(resource.ItemSpec, relativePath);

PR Checklist ✅

Copilot AI self-assigned this Jun 4, 2026
Copilot AI review requested due to automatic review settings June 4, 2026 10:46
Copilot AI removed the request for review from Copilot June 4, 2026 10:46
Copilot AI linked an issue Jun 4, 2026 that may be closed by this pull request
2 of 11 tasks
Copilot AI requested review from Copilot and removed request for Copilot June 4, 2026 10:53
@CLAassistant

CLAassistant commented Jun 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ MartinZikmund
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix resource localization issue in iOS when project is in OS folder [iOS] Fix resource language detection when project path contains OS Jun 4, 2026
Copilot AI requested a review from MartinZikmund June 4, 2026 10:54
@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@github-actions github-actions Bot added area/code-generation Categorizes an issue or PR as relevant to code generation area/automation Categorizes an issue or PR as relevant to project automation labels Jun 5, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund marked this pull request as ready for review June 5, 2026 15:55
Copilot AI lite review requested due to automatic review settings June 5, 2026 15:55

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

This PR fixes iOS localization resource generation when absolute filesystem paths contain segments that look like locale qualifiers (e.g., .../OS/...), by basing qualifier parsing on MSBuild-provided item-relative paths (TargetPath) instead of the machine’s full path. It also adds a unit test to cover the absolute-path + relative-target-path scenario to prevent regressions.

Changes:

  • Update ResourcesGenerationTask_v0 to parse ResourceCandidate using TargetPath (fallback: ItemSpec) for relative qualifier detection.
  • Add a unit test verifying correct logical path + language extraction when ItemSpec is absolute but TargetPath is relative.

Reviewed changes

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

File Description
src/Uno.UI.Tests/Resources/Given_ResourceCandidate.cs Adds regression test for parsing qualifiers from a relative target path even when the full path contains misleading segments like OS.
src/SourceGenerators/Uno.UI.Tasks/ResourcesGenerator/ResourcesGenerationTask.cs Switches resource qualifier parsing to prefer MSBuild-relative TargetPath rather than absolute ItemSpec.

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

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI and others added 3 commits August 3, 2026 14:10
Language detection parsed the resource's full filesystem path, so any
directory above the project whose name is a language tag was picked up as
a qualifier. A project under a folder named `OS` (Ossetic) or `cs` (Czech)
got that folder as its language, emitting `OS.lproj` on iOS and the wrong
`values-*` on Android.

Qualifiers are now read from the authored, project-relative path: `Link`,
then a relative item spec, then the item spec with the defining/target
project directory stripped. `TargetPath` alone is not enough, since
AssignTargetPath collapses items outside the project cone to their bare
file name, which would drop the language of resources referenced through
a relative path such as `..\Shared\Strings\de\Resources.resw`.

fixes #3157
fixes #4657

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XTnhSeNXbqgHyJqjFdfNx2
@MartinZikmund
MartinZikmund force-pushed the copilot/fix-resource-localization-ios branch from ba3145b to 358e4ad Compare August 3, 2026 12:26
Copilot AI review requested due to automatic review settings August 3, 2026 12:26

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.

🟡 Not ready to approve

The new resolver should normalize path separators before using Path.* APIs/returning the qualifier path, otherwise qualifier parsing can still break when metadata uses non-native separators (notably on macOS/Linux).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (1)

src/SourceGenerators/Uno.UI.Tasks/ResourcesGenerator/ResourceQualifierPathResolver.cs:36

  • ResourceCandidate.Parse relies on Path.GetDirectoryName/Path.DirectorySeparatorChar, so if MSBuild provides Link/TargetPath/ItemSpec with non-native separators (e.g. \ on macOS/Linux), the current resolver may fail to detect directory structure and qualifiers, falling back to the absolute path (reintroducing the OS/cs language mis-detection). Normalize path separators up-front before running Path.* APIs and returning the qualifier path.
		if (string.IsNullOrEmpty(itemSpec) || !Path.IsPathRooted(itemSpec))
		{
			// A relative item spec is authored as-is and already relative to the project.
			return itemSpec;
		}
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

`Link` and `TargetPath` metadata keep the separator the project authored,
while qualifiers are split on the build host's separator. A Windows-authored
`\` therefore yields no folder qualifiers on a mac or Linux host.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VLFYcoiAFBfeEpH1R2MaNi
Copilot AI review requested due to automatic review settings August 4, 2026 12:18

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.

🟢 Ready to approve

The fix is narrowly scoped, aligns with the reported issues, and includes focused unit tests that exercise the problematic path/metadata combinations.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@MartinZikmund
MartinZikmund enabled auto-merge August 4, 2026 12:22
@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund merged commit 46d46ac into master Aug 4, 2026
70 checks passed
@MartinZikmund
MartinZikmund deleted the copilot/fix-resource-localization-ios branch August 4, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/code-generation Categorizes an issue or PR as relevant to code generation

Projects

None yet

6 participants