App Localization (Xamarin Community Toolkit)

Play App Localization (Xamarin Community Toolkit)

The Discussion

  • User profile image
    Countryen

    Thanks for showing and integrating this in the XCT. Does this only aid when switching languages at runtime, or is there any other benefit you should use this instead of x:Static?

    Also, I think the shown example to registering the INPC-event is a bit quick and dirty, as the culture will be set every time any INPC-Property of the manager changes, am I wrong? Besides, is it recommended (or doesn't matter) to not unregister the INPC-event?

    The ResX Manager looks cool, would be a nice addition to the links under the video.

  • User profile image
    Maxc137
    Countryen, thanks for the comment!

    "Does this only aid when switching languages at runtime"
    Localization classes from XCT allow you to update their value. This is usually only needed on language change.
    - LocalizationResourceManager is only needed to notify listeners that language has changed.
    - TranslateExtension is only useful for runtime language change. There is no reason to update string from app resource except when language has changed, so x:Static would work fine there.
    - LocalizedString is more interesting. Since it's value is generated in code, it can change even when language stays the same. So you can use it with one language, and manually call OnPropertyChanged when you need to update it's value on the view.

    "I think the shown example to registering the INPC-event is a bit quick and dirty"
    It may seem like that, but everything is accounted for =)
    - The only property that LRM has is CurrentCulture, so if PropertyChanged is fired, it's because CurrentCulture has changed (also there is a check in ObservableObject.SetProperty that value is different)
    - Also thanks to ObservableObject (that LRM is inherited from) PropertyChanged event is implemented using WeekEventManager, so you don't need to unsubscribe from it. (Besides, LRM.Current is static, so it will never be collected anyway)

    Regarding ResX Manager. Good point! I'll add a link to it in Readme for demo app, and ask to add it here.

Add Your 2 Cents