How to use multi-languages for iPhone application using MonoTouch?

旧时模样 提交于 2019-12-02 21:00:31
Thomas Rosenstein

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)

The File looks like that:

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

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

you use it that way:

// don't forget the using

"My String".t();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!