bha*_*ath 11 iphone monodevelop xamarin.ios
如何在iPhone应用程序中使用多种语言?目前我只使用英语.但是将来我想要使用大约20到30种语言.如何在使用MonoTouch的iPhone开发中使用它?
Tho*_*ein 26
您必须以"language.lproj"格式为您使用的每种语言创建一个文件夹(例如en.lproj,de.proj) - 在那里您必须创建一个名为Localizable.strings的文件(编译操作:内容)
文件看起来像这样:
"Name For Your String"="Translation For Your String"; // don't forget the semicolon!
Run Code Online (Sandbox Code Playgroud)
然后你可以调用NSBundle.MainBundle.LocalizedString("Name for YourString","","")
这是一个简短的扩展方法,使翻译更容易:
public static class Extension
{
public static string t(this string translate)
{
return NSBundle.MainBundle.LocalizedString(translate, "", "");
}
}
Run Code Online (Sandbox Code Playgroud)
你这样使用它:
// don't forget the using
"My String".t();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4384 次 |
| 最近记录: |