ReachContact / GCTactical-Issues

This is Issue Tracker for the GCTactical Solution
0 stars 0 forks source link

Resources / Localisation - Cross Platform #13

Closed dazinator closed 9 years ago

dazinator commented 9 years ago

Consider this code in an android project:

Resources.GetString(Resource.String.OK)

This resources and localisation system is only accessible within an android project.

Imagine we have a re-usable viewmodal (for example a login screen) that's shared between android and ios. Imagine it needs to expose a property to the View but the property needs to be some localised text - for example "Login denied. Invalid credentials".

Currently we would have to duplicate this resource / text into the ios project resources system, and then each view (android / ios) need to have a an implementation of an ILoginView method which the platfrom agnostic code can call so the platform specific view can load the appropriate resource and perhaps set some control's text value.

If we have a cross - platform Resource / Localisation system, this wouldn't be necessary as we could have an IResourceProvider interface, which the platform agnostic code makes use of to grab resource / localised text. We would then have a Droid / IoS implementation of that interface for Droid / ios registered into the IoC container of App startup. The platform agnostic code can now access resources freely, so for example, for shared view models, the view model can now expose a string property containing the message. The view code can use existing databinding techniques to bind it's control to the view model text property. This eliminates the amount of code required in the view, which also has to be duplicated per platform.

MvvmCross allready comes with a plugin for a platform agnostic text localisation system. However it requires that you put all your strings / text into json files in a common project. This is opposed to defining recources in each project (ios / android etc). Investigate if we could do something like this.

dazinator commented 9 years ago

Now using mvvmcross json based localisation system. Localised strings are in json files in the Core project.