RESX Localizing iOS Assembly can't be added?

We are using RESX Resource files to localize our app. In the tutorial https://developer.xamarin.com/guides/cross-platform/xamarin-forms/localization/ it tells me to add the assembly dependency but when i want to build my project I found out that Dependency takes two arguments. What is the right way to do this?

using System;
using Foundation;
using System.Runtime.CompilerServices;


[assembly:Dependency(typeof(myApplicationName.Localize))]

namespace myApplicationName
{
    public class Localize
    {
        public System.Globalization.CultureInfo GetCurrentCultureInfo ()
        {
            var netLanguage = "en";
            if (NSLocale.PreferredLanguages.Length > 0) {
                var pref = NSLocale.PreferredLanguages [0];
                netLanguage = pref.Replace ("_", "-"); // turns es_ES into es-ES

                if (pref == "pt")
                    pref = "pt-BR"; // get the correct Brazilian language strings from the PCL RESX
                //(note the local iOS folder is still "pt")
            }
            return new System.Globalization.CultureInfo(netLanguage);
        }
    }
}

Answers

  • TobiasRddigerTobiasRddiger DEUniversity
    edited September 2015

    Hi @M.RIYAZ

    Thank you very much for your answer! :smile: I'm developing for Xamarin.iOS and I can't manage to add the dependency to Xamarin.Forms.

    Right now I've localized the app by adding en.lproj folder, de.lproj folder and so on to my iOS solution. I've then created a class with a static method to make the NSBundle.MainBundle.LocalizedString(string key, string value) call a little shorter. I've also written a little script to translate the resx files into the right format for the iOS solution. I'd still prefer to use the resx files due to less overhead in the future development process.

    Any ideas?

    Best regards! :)

  • TobiasRddigerTobiasRddiger DEUniversity

    Hey @rzee7

    any updates? :)

    Best,
    Tobi

  • rzee7rzee7 INUniversity ✭✭✭✭✭

    Hey @wasserglas! Sorry about the delay and Thanks for the buzz!! :)

    Yes I have done and will post you soon this weekend, We have Diwali festival here in India just busy in that. :)

    Thanks
    RIYAZ

Sign In or Register to comment.