Localization best practices

GadiPazGadiPaz ILUniversity

I'm porting my app to Xamarin.Forms.
'Till now I used MVVMCross (i18n) and I would like to use only Xamarin.Forms.

I read about Vernacular, maybe .resx files on the shared project...
I would like to have the ability to write something like: getString("Dog") and get the appropriate string according to current device locale.
Of course the idea is holding the resources strings in one place (maybe in the Shared Project or PCL)

What is the best way to do that?

Answers

  • MihaMarkicMihaMarkic ✭✭✭✭ SI ✭✭✭✭
    edited June 2014

    Not sure if XAML custom markup support is there thus I'd consider using a static class that'd be accessed through {Static} binding if talking XAML. If binding/setting properties in code then use whatever mechanism you wish.
    NOTE that you can build such a static file that holds all text as properties using a code generator (T4, CodeSmith, ...)

    Or this, which looks a better way.

  • StephaneDelcroixStephaneDelcroix ✭✭✭✭ USInsider, Beta ✭✭✭✭

    Xaml supports custom markup renderers. I also merged support for Xamarin.Forms xaml into vernacular a few days ago. I still have to write the doc for that

  • GadiPazGadiPaz ILUniversity

    MihaMarkic, I'm looking for a clear example code, I didn't find any on the net. but Thanks for your response :)
    StephaneDelcroix, first of all thank you.
    It's kinda hard to understand how Vernacular works,
    can you please provide a small example code which clarify how to use vernacular with Xamarin.Forms?
    It'll be very helpful for us (vernacular newbies)

    Thank you in advanced

  • MihaMarkicMihaMarkic ✭✭✭✭ SI ✭✭✭✭

    Did you check CraigDunn's link within my second link?
    Here is another thread.

  • GadiPazGadiPaz ILUniversity

    I'll try implementing this in my code, I still didn't find any sample application but the "another thread" you provided seems promising

Sign In or Register to comment.