本地化的Xamarin.iOS [英] Localization on Xamarin.iOS

查看:124
本文介绍了本地化的Xamarin.iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出定位上Xamarin.iOS。我是新来的总体定位,但我们要做的第一语言是冰岛。如果你看对了iOS设备本身的设置冰岛不是一个选项。所以这是一个问题的两个部分。

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.


  1. 我如何设置我的应用程序中的定位?难道我只是在定位相同的方式与其他.NET apps..or有没有一些具体的事情到iOS / Xamarin,我需要做的。

  1. 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.

在我实现这一点,我怎么得到它选择冰岛作为语言,因为iOS不把它作为可用的语言?

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.

推荐答案

如何建立本土化之内我应用?

iOS版都有自己的方法来处理本地化。对于每种语言需要在您的项目命名为创建一个文件夹 language.lproj ,其中语言是ISO 639-1或ISO 639-2语言代码。两个字符的ISO 639-1代码是优选的(例如,en,德国,法国,它...)。你可以找到与ISO 639-1和639-2 ISO代码这里表。

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.

在新创建的文件夹,您需要创建 Localizable.strings 命名的文件,在这里你可以添加你的字符串要本地化:

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=这是翻译;

和分配一个本地化的字符串,例如一个的UILabel

And to assign a localized string for example to a UILabel:

UILabel label = new UILabel();
...
label.Text = NSBundle.MainBundle.LocalizedString("stringToLocalize", null);

您甚至可以创建一个扩展方法(信贷的anotherlab ):

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, "", "");
    }
}



如何得到它选择冰岛作为语言,因为iOS不把它当作一个可用的语言?

我不认为有一种方法来选择冰岛在iOS的一种语言。我们的一个应用程序的使用德语,意大利语和法语的本地化。因为我们并不需要英语,我们创建 en.lproj 文件夹在它的德国本地化。这种方式,即使该装置的语言设置为英语,德语文本将出现。也许你可以做这样的事情太您的应用程序。

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.

这篇关于本地化的Xamarin.iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆