如何使用MonoTouch为iPhone应用程序使用多语言? [英] How to use multi-languages for iPhone application using MonoTouch?

查看:120
本文介绍了如何使用MonoTouch为iPhone应用程序使用多语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iPhone应用程序中使用多种语言?目前我只使用英语。但是将来我想用大约20到30种语言。如何在使用MonoTouch的iPhone开发中使用它?

How to use multi languages for iPhone application?. Currently I used english language only. But in future I want to use around 20 to 30 languages. How to use it in iPhone development using MonoTouch?

推荐答案

您必须为格式化的每种语言创建一个文件夹language.lproj(例如en.lproj,de.proj) - 在那里你必须创建一个名为Localizable.strings的文件(编译动作:内容)

You have to create a folder for each language you are using in the format "language.lproj" (e.g. en.lproj, de.proj) - in there you have to create a file called Localizable.strings (Compile Action: Content)

文件看起来像这样:

"Name For Your String"="Translation For Your String";     // don't forget the semicolon!

然后你可以调用NSBundle.MainBundle.LocalizedString(Name For YourString,, )

then you can call NSBundle.MainBundle.LocalizedString("Name For YourString", "", "")

这是一个简短的扩展方法,使翻译更容易:

Here's a short extension method which makes the translation a little easier:

public static class Extension
{
   public static string t(this string translate)
   {
      return NSBundle.MainBundle.LocalizedString(translate, "", "");
   }
}

你这样使用它:

// don't forget the using

"My String".t();

这篇关于如何使用MonoTouch为iPhone应用程序使用多语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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