WindowsAppSDK
WindowsAppSDK copied to clipboard
Support PrimaryLanguageOverride from unpackaged apps
when calling the following code from an unpackaged app, it throws an error. This is needed to be able to use x:Uid
localization in XAML and control the language it picks.
App::App()
{
...
Windows::Globalization::ApplicationLanguages::PrimaryLanguageOverride(...)
...
}
Hi @shelllet, this API isn't intended to work from an unpackaged context.
Additionally, we've started a list of APIs like this that don't work from unpackaged apps that we need to either (1) document better with warnings so you know before you try using it, or (2) add new WinAppSDK APIs that work for unpackaged apps: #1702
So what Api should I call to set the defualt language?
@axelandrejs how should unpackaged apps set their default language for resolving resources and XAML localization?
MRTCore determines the default language using Windows::Globalization::ApplicationLanguages::Languages (https://github.com/microsoft/WindowsAppSDK/blob/main/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceContext.cpp#L106-L113)
@huichen123 but how should unpackaged apps change the default language for their app? As shelllet pointed out, in a packaged app, developers can call ApplicationLanguages::PrimaryLanguageOverride('en-us')
to override the default language, but that API doesn't work for unpackaged apps. How should unpackaged apps override the default language when using MRT Core?
Many apps (including my own) allow the user to pick their own language independent from the OS language.
Before PrimaryLanguageOverride is fixed, you may have to pass in a ResourceContext, and set its Language qualifier value to the desired value.
Before PrimaryLanguageOverride is fixed, you may have to pass in a ResourceContext, and set its Language qualifier value to the desired value.
Will these unpackaged API be fixed before GA version? This breaks x:Uid localization and seems to have no workaround.
sorry, it will not be fixed for GA.
Re-opening this, as it's something we should implement at least someday so that unpackaged apps can use XAML x:Uid
localization and control the language the app uses.
Tagging it as a bug too, this definitely is somewhere between bug and "feature", but since the overall scenario of localizing your unpackaged app with control over the language doesn't work, I'll add the bug tag.
Hi @andrewleader any news? can we expect this feature/bugfix in WASDK 1.1/preview/experimental?
@huichen123 is the owner of this feature/bug and maybe can speak toward whether this would be in 1.1.
And FYI Mahdi, I moved to a different project in Microsoft, the right person to contact with general WinAppSDK questions would be marb2000. Thanks!
@huichen123 Hi! Any news on this? Convenient globalization is an indispensable feature for unpackaged apps to use WinAppSDK. 😋
Windows.Globalization.ApplicationLanguages was designed for packaged app. Instead of inventing local settings for unpackaged app, it might be easier WinUI can take ResourceManager/ResourceContext from app. @evelynwu-msft ?
Windows.Globalization.ApplicationLanguages was designed for packaged app. Instead of inventing local settings for unpackaged app, it might be easier WinUI can take ResourceManager/ResourceContext from app. @evelynwu-msft ?
Agreed with this. Language is not the only interesting setting here. EG, what about scale or theme? The way to set these is via the context, so that context should be exposed.
Windows.Globalization.ApplicationLanguages was designed for packaged app. Instead of inventing local settings for unpackaged app, it might be easier WinUI can take ResourceManager/ResourceContext from app. @evelynwu-msft ?
Agreed with this. Language is not the only interesting setting here. EG, what about scale or theme? The way to set these is via the context, so that context should be exposed.
That's still on the books for 1.2ish (http://task.ms/37146452), but nothing is planned in this space for 1.1.
Hello, is there any update on when will this be implemented? Currently, there is no easy way to localize the strings in XAML for an unpackaged app, which is very frustrating😞
As a workaround, I published a NuGet package called WinUI3Localizer (nuget.org/GitHub) that also works with unpackaged apps. It uses the general Resources.resw strings, so you should be able to switch back when the WinUI team comes with a solution 😎
I am hitting this issue when attempting to support language changes from an unpackaged XAML islands (non-WinUI 3) app. The API works as expected when the app is packaged. What should I do? I don't think system XAML uses MRTCore.
Is anyone working on this?
any news? @evelynwu-msft we are in 1.4-preview1 and we cant change app language!
good news https://github.com/microsoft/WindowsAppSDK/pull/4181
Doesn't solve my problem :(
I am hitting this issue when attempting to support language changes from an unpackaged XAML islands (non-WinUI 3) app. The API works as expected when the app is packaged. What should I do? I don't think system XAML uses MRTCore.
@sylveon Can you provide a sample app? Thanks.
Any app using system XAML islands will fail when trying to use Windows::Globalization::ApplicationLanguages::PrimaryLanguageOverride
without being packaged. WASDK cannot solve this without a complete migration to WinUI 3, which is non-trivial.