I followed the tutorial in this youtube Video by Geralt about Multilingual on .NET MAUI, very good and very detailed: https://www.youtube.com/watch?v=cf4sXULR7os
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.GetObject(resourceKey, Language.Culture) ?? Array.Empty<byte>();
public void setCulture(CultureInfo culture) => Language.Culture = culture;
}
}
To be able to detect CultureInfo change. On each XAML Page, I have to write and call the event like this:
In PAGE Contructor i write:
ResourceModels.Obj.PropertyChanged += Obj_PropertyChanged;
And this method for that:
private void Obj_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
ResourceModels.Obj.setCulture(CultureInfo.CurrentCulture);
}
It is really troublesome when working with a project with many PAGE, and I am not working on only 1 project.., please everyone show me how to do this Global Real-Time once and for all. And this will live forever from the moment I open the application until I exit the application.