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

查看:16
本文介绍了如何使用 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天全站免登陆