Localization in .NET MAUI - Adding Multi-Language to Your Apps
Why Stack Overflow recommends it
Stack Overflow users link it as the reference implementation for MAUI localization, both when answering how to refresh the UI after a culture change and when asking follow-up questions about problems that come up while following it.
Recommended by 2 people across 2 different months, 2023 to 2024.
What it is
A 24-minute tutorial by Gerald Versluis on adding multi-language support to .NET MAUI apps using resx resource files. It walks through three increasingly capable approaches, including a LocalizationResourceManager that updates the UI when the language changes, a XAML markup extension, and translating strings from code with parameters.
What people said
Recommends Serge Misnik · 2023-07 · Stack Overflow · on “How to reload or update UI in .Net MAUI, when culture has been changed?”
Resetting AppShell is bad idea and may lead to numerous bugs. I've used this [this video] solution and it works great. Basically, you'd need a localization manager and a markup extension: public class LocalizationManager : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private static readonly Lazy<LocalizationManager> _instance = new(()=> new LocalizationManager()); private LocalizationManager() { Properties.Resources.Culture = CultureInfo.CurrentUICulture; } public static LocalizationManager Instance => _instance.Value; public object this[string resourceKey] => Properties.Resources.ResourceManager.GetObject(resourceKey, Properties.Resources.Culture) ?? string.
Recommends Hưng Nguyễn · 2024-06 · Stack Overflow · on “.NET MAUI Real-Time Detect Current CultureInfo Changed?”
I followed the tutorial in this youtube Video by Geralt about Multilingual on .NET MAUI, very good and very detailed: [this video] After many times I Googled the results from StackOverFlow, I could not find the answer for myself. I have a MVVM class like this: namespace MyNameProject.Models { [ContentProperty(nameof(Name))] public partial class ResourceModels : ObservableObject, IMarkupExtension<BindingBase> { private ResourceModels() => Language.Culture = CultureInfo.CurrentCulture; private static ResourceModels obj; internal static ResourceModels Obj { get { if (obj == null) obj = new(); return obj; } set => obj = value; } public object this[string resourceKey] => Language.ResourceManager.GetOb
Cites Tim · 2023-07 · Stack Overflow · on “How to solve the problem about loading resx resources dll on iOS (.NET MAUI)”
Background: I want to do the localizations feature on my .NET MAUI app. I follow this video ( [this video] ) to do that. [LINK] In the iOS simulator, the localization feature and loading the resources.dll is running preferably. (like the following) [LINK] But once I deploy it to my physical iPhone device, the feature does not work and outputs the following message when I change the language. Language is Traditional Chinese 2023-07-12 01:10:01.410 Xamarin.PreBuilt.iOS[645:115119] Could not resolve assembly TestApp.resources, Version=1.0.0.0, Culture=zh-TW, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/1F073A32-D7F4-4009-81C6-D12526416BC2/Doc
Cites torof · 2024-12 · Stack Overflow · on “Localization with expression-based bindings”
I'm following Gerald Versluis tutorial on Localization in .NET MAUI [this video] . He use the following extension for localizing texts in XAML: [ContentProperty(nameof(Name))] public class TranslateExtension : IMarkupExtension<BindingBase> { public string Name { get; set; } public BindingBase ProvideValue(IServiceProvider serviceProvider) { return new Binding { Mode = BindingMode.OneWay, Path = $"[{Name}]", Source = LocalizationResourceManager.Instance }; } object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) { return ProvideValue(serviceProvider); } } But this gives the warning: IL2026: Using member 'Microsoft.Maui.Controls.Binding.Binding()' which has 'RequiresUnreferencedCode