开发者

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

开发者 https://www.devze.com 2023-03-11 04:28 出处:网络
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. Ho开发者_开发技巧w to use it in iPhone development us

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. Ho开发者_开发技巧w to use it in iPhone development using MonoTouch?


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消