microsoft / microsoft/microsoft-ui-xaml

Handle Multi Lang Strings in XAML base C++ WinRT Unpackaged application

Open
#10,393 6 comments 0 reactions 0 assignees View on GitHub
area-C++/WinRT bug group-language team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

My application is - WinUI3 XAML based C++WinRT, **Unpackaged** App
for handling MultiLanguages strings, I am implementing .resw files.
[Microsoft.Windows.CppWinRT version 2.0.240405.15]

There are two resw files

Englishtext
Strings/en-US/Resources.resw

Polish text
Strings\pl-PL\Resources.resw

Problem :- I get the text of the Lang which is set as Preferred Lang in settings.
If it is a Polish machine and user has changed the "Preferred Languages" to English instead of Polish. (Settings -> Time&Language -> Lang & Region -> Preferred Languages ), then it picks English string NOT the Polish one.

Is there any way to set the Language as per our need in c++ WinRT app in such a way that my app will pick Polish text only... irrespective of what is set as Default Preferred lang.

I tried to set DefaultLang by using winrt::Windows::Globalization::ApplicationLanguages::PrimaryLanguageOverride but it throws exception message "The process has no package identity".

Thanks,
MChauhan

### Steps to reproduce the bug

-

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

None

### Windows version

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the resource paths Strings/en-US/Resources.resw and Strings/pl-PL/Resources.resw, then trace the use of Windows.Globalization.ApplicationLanguages::PrimaryLanguageOverride in an unpackaged C++/WinRT app. Reproduce the preferred-language behavior and package-identity exception; done means establishing a supported way to select Polish or documenting the limitation clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, localization
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.