2011-06-07 139 views

回答

26

您必须为格式为“language.lproj”的每种语言(例如en.lproj,de.proj)创建一个文件夹 - 在那里您必须创建一个名为Localizable.strings的文件(Compile Action :内容)

文件看起来像这样:

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

,那么你可以调用NSBundle.MainBundle.LocalizedString( “名称对于YourString”, “”, “”)

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

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

你用这种方式:

// don't forget the using 

"My String".t(); 
+0

感谢托马斯。所以我需要为此手动翻译所有英文单词。对?有没有其他方法? Google翻译怎么样? – bharath 2011-06-08 06:20:12

+0

您可以只复制未翻译的字符串并翻译它们,但我只会使用英语而不是谷歌翻译 对于每个单词的翻译,您会为他们翻译的每个单词付费提供各种翻译服务。 – 2011-06-08 12:50:02

+0

我用动态词。基本上所有的值只来自服务器。如果用户想要更改语言,就意味着我需要在应用程序中进行更改。我不想再为此调用服务器。 – bharath 2011-06-08 13:02:32

相关问题