I'm trying to figure out localization on Xamarin.iOS. I am new to localization in general, but the first language we want to do is Icelandic. If you look on the settings for the iOS device itself Icelandic is not an option. So this is a two part question.
How can I set up localization within my app? Do I just localize in the same manner as other .net apps..or is there something specific to iOS/Xamarin that I need to do.
Once I implement this, how do I get it to choose Icelandic as the language since iOS does not have it as an available language?
Documentation seems to be sparse on this topic.
Localizing The MessageApple also customizes its stores based on their location. The company has more than 500 Apple stores worldwide and makes a point to tailor each to its geographic region.
Click on iOS->App/Single View App->Next. Name your project and select the language as Swift. Select a desired location and click on Create. To start with Localization, click on your Project Name -> go to Info Tab -> Under Localizations, click on the '+' button.
How can I set up localization within my app?
iOS has its own way to handle localizations. For each language you need to create a folder in your project named language.lproj
where language
is ISO 639-1 or ISO 639-2 language code. Two character ISO 639-1 codes are preferred (e.g. en, de, fr, it, ...). You can find a table with ISO 639-1 and ISO 639-2 codes here.
In your newly created folder you need to create a file named Localizable.strings
and here you can add your strings which you want to localize:
"stringToLocalize" = "This is the translation";
And to assign a localized string for example to a UILabel
:
UILabel label = new UILabel();
...
label.Text = NSBundle.MainBundle.LocalizedString("stringToLocalize", null);
You can even create an extension method (credit to anotherlab):
public static class LocalizationExtensions
{
public static string t(this string translate)
{
return NSBundle.MainBundle.LocalizedString(translate, "", "");
}
}
How do I get it to choose Icelandic as the language since iOS does not have it as an available language?
I don't think there is a way to choose Icelandic as a language in iOS. One of our apps uses German, Italian and French localizations. Since we don't need English we created en.lproj
folder with German localizations in it. This way even if the language of the device is set to English, German texts will appear. Maybe you can do something like this too in your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With