Search code examples
iosxamarinmvvmcross

MVVMCROSS Changing Language in iOS


I'm trying to implement a multilanguage support with mvvmcross in iOS. The "languages" are stored in a .resx file in the core (Portable Library Class).

So on the android side it works great......I have just to call the recreathe()-Method to rebuild the views.

Is there some similiar method I can call in iOS or in the MVVMCROSS-Library? I experimented a lot with several methods, but without any success.

I know how to make it manually:

  • Remove all Subviews
  • Create new instances for each removed subview
  • Do the bindings again
  • Add the views back to subviews

But honestly this just can't be the way it goes. Has anyone a much more sleek suggestion?


Solution

  • if your views use binding (like I described here ) to display the localized version of the string values, the only thing you need to do is to call RaisePropertyChanged(string.empty) or RaiseAllPropertiesChanged() on the view-models

    When user changes the language, you could broadcast a message (using MvmCross messenger) which all the language aware view-models listen to, and on handling this message have the view-models can then call RaisePropertyChanged(string.empty) or RaiseAllPropertiesChanged() on the view-models