2011-06-07 70 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

相關問題