Problems with iOS Localization

PedroRodrguezPedroRodrguez USMember ✭✭

Hi mates! I have problems with iOS Localization.

I followed this guide to insert localization strings in my app.

Finally, I have this folders in my project:

and I added to my Info.plist the following keys at top of the file:

And, in code, I'm recovering the translations with:

var localizedString = NSBundle.MainBundle.LocalizedString ("key", "optional");

but doesn't work. I'm getting the key when going to show the translation.

I'm working with iPhoneSimulator and Visual Studio 2015. Could give me some help to solve this? I'm tried everything to solve, but still blocked :(.

Thanks in advance!

Best Answer

  • PedroRodrguezPedroRodrguez US ✭✭
    Accepted Answer

    Hi @josemmortega

    Thanks for your answer! Finally I found the solution:

    I had to create Resource Folders with type "BundleResource". I could check it taking a look in .csproj file.

    Thanks again for your answer!

    Best Regards

Answers

  • josemmortegajosemmortega ESUniversity ✭✭✭
    Hi, @PedroRodrguez

    My advice, avoid localization inside of platform.

    I recommend use this lib https://github.com/xleon/I18N-Portable

    Works really well.

    Regards
  • PedroRodrguezPedroRodrguez USMember ✭✭
    Accepted Answer

    Hi @josemmortega

    Thanks for your answer! Finally I found the solution:

    I had to create Resource Folders with type "BundleResource". I could check it taking a look in .csproj file.

    Thanks again for your answer!

    Best Regards

  • josemmortegajosemmortega ESUniversity ✭✭✭
    Sounds great, but sincerely it's really recomendable use a shared localized strategy
  • ElenaBolpachovaElenaBolpachova USMember ✭✭

    Hi @PedroRodriguez !

    I seem to be having the exact same problem you do, however I am required to make the localization work from within the iOS project, so unfortunately doing that in a PCL or other shared code is not an option for me...

    I've tried with a helper translate extension method I found on another thread here, but again it didn't work.

    My .lproj files are all with BundleResource build action, so I am lost. Do you have any other ideas I could try?

    What has me slightly worried is this bug reported in the Xamarin bugzilla, which as far as I can tell couldn't be reproduced so no one fixed it: https://bugzilla.xamarin.com/show_bug.cgi?id=36707

    Any help is greatly appreciated! :)

  • SuatKorkmazSuatKorkmaz USMember ✭✭✭

    @PedroRodrguez said:
    Hi @josemmortega

    Thanks for your answer! Finally I found the solution:

    I had to create Resource Folders with type "BundleResource". I could check it taking a look in .csproj file.

    Thanks again for your answer!

    Best Regards

    What do you mean "Resource Folders with type "BundleResource""?

  • Marcel_BeMarcel_Be Member

    @josemmortega said:
    Hi, @PedroRodrguez

    My advice, avoid localization inside of platform.

    I recommend use this ...

    Works really well.

    Regards

    I doesn't recommend that. No coverage and lower version 1. For production not the best choice.

    Regards

  • josemmortegajosemmortega ESUniversity ✭✭✭
    @Marcel_Be what it's the real problem?
  • Marcel_BeMarcel_Be Member

    @josemmortega For me the main problem is nuget version lower 1 (0.6.0). For me it means, it is under development. But the last commit was one year ago. But that's just my opinion and why I wouldn't use it.

  • josemmortegajosemmortega ESUniversity ✭✭✭

    It's your only reason @Marcel_Be, version number? Idk, I use this library in production and work really well.

  • This library works very well for me to into my productions apps

  • diegoxleondiegoxleon ESMember ✭✭
    edited August 2018

    I doesn't recommend that. No coverage and lower version 1. For production not the best choice.

    Regards

    Hi @Marcel_Be
    Thanks for you comments on I18n-portable library.
    The coverage is actually greater than 99%, however codecov.io doesn´t seam to be working at the moment. You may clone the project and run the test suite by yourself before doing such statements.
    This library is being used my many people on production (me included) without issues. The reason for the version being less than 1 is that I had plans to implement more features but I decided to keep it simple instead. Anyway you are right, it might change to a 1.0 version soon, as I´m planing to create some handy tools like static reference keys.

Sign In or Register to comment.