I want try to use .resx
files for localization in my .NET 9 Maui app. My resource file is in the Resources
folder like:
/Resources/Languages/Resources.en.resx
with a key "title".
I try to access this in my views as follows:
xmlns:lang="clr-namespace:MyApp.Resources.Languages"
Title="{x:Static lang:Resources.title}">
It tells me the CLR namespace could not be found. For some reason in .NET 9, you can't access the Resources
folder like this anymore.
I already tried various approaches I found on Stackoverflow, but it seems be a .NET 9 specific problem.
I'd be happy if anyone could tell me how to use localization in .NET 9 MAUI apps.
EDIT - Solution For some reason in net9 it has to be named AppResources like AppResources.de.resx which is not clear by documentation (at least at this momenta)
.NET MAUI 9 localization handles things a bit differently.
In your case, .xaml is expected to look like something below assuming the resource file is named as AppResources
.
<ContentPage ...
xmlns:strings="clr-namespace:<your-project-name>.Resources.Languages">
...
<Label Text="{x:Static strings:AppResources.title}"/>