I haven't writing in english for a while.
Today I accomplished a new goal, adding localization for different languages on the Workout.Me app.
It was really easy to do. By the moment I just defined some strings in two resource files, one in english and another in spanish.
To try this feature, I added a menu item to the AppShell flyout, which just do switch the languages. Actually the method, first changes the CultureInfo and then send a multicast message through the MessagingCenter class.
Then simply call the Send method:
MessagingCenter.Send<AppShell>(this, "LanguageChanged");
And then, in each desired class, it's necessary to suscribe to that message:
MessagingCenter.Subscribe<AppShell> (this, "LanguageChanged", (sender) =>
{
//ApplyLanguage();
});
So clean, effective and easy to implement. Beautiful.
No hay comentarios:
Publicar un comentario