-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle Multi Lang Strings in XAML base C++ WinRT Unpackaged application #10393
Comments
var resourceManager = new ResourceManager();
var resourceContext = resourceManager.CreateResourceContext();
resourceContext.QualifierValues["Language"] = "fa-IR";
var candidate = resourceManager.MainResourceMap.TryGetValue($"Resources/{key}", resourceContext);
var value = candidate != null ? candidate.ValueAsString : key; when you are working with WinUI, always make sure you are using Microsoft.* namespaces and not Windows.* |
There are two things to remember here, there isn't a "Polish" version or an "English" version of Windows. There are versions of Windows with an English language pack and a Polish language pack installed. Even single language versions of Windows Home can have the language pack changed if you know what you are doing. Secondly, the language that Windows is set to display is the user's preferred setting. Having an application just outright ignore that isn't a nice thing. You really should have an in app setting if you want to do this, but be sure that you default to the user's preference. I normally have two language packs installed on my system. I completely expect any application to show my preferred display language by default, always. |
Hi, My application is C++ WinRT based WinUI3 app. I can change the default Lang setting in same way you did in your shared c# code. But that does not solve my concern. By doing so I need to Set the text for each control in c++ code. I want to do something like shared in This Video(C#). Thanks. |
Did you include the appropriate header? Are you using the Windows App SDK 1.6, because Microsoft.Windows.Globalization.ApplicationLanguages is documented. As a convention, we normally refer to these by the WinRT namespace name, but when you see Microsoft.Windows.Globalization, you should automatically convert this to Microsoft::Windows::Globalization for C++. C++/WinRT then also adds on winrt as the projection namespace normally, but this can actually be configured. |
Yes I am using WindowsAppSDK 1.6.250108002. Like I said the problem seems to be with ApplicationLanguages::PrimaryLanguageOverride property that does not work for Unpackaged WinUI3 XAML based C++WinRT. I found the same issue mentioned in other few threads also. Thanks |
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
The text was updated successfully, but these errors were encountered: