2013-05-28 70 views
3

我已经构建了一个iOS应用程序,并将该应用程序翻译为英文和瑞典文。 我面临的问题是,一个英语单词在瑞典语中可以有两个不同的含义(翻译)。所以现在我把英文单词作为关键和价值。 我希望能够拥有一个按键,我可以随心所欲地调用它,并为其设置英文值以及瑞典值,这样我就可以用两种不同的单词将其翻译为瑞典语,并保留相同的单词为英语。iOS - 本地化的最佳实践

我该如何实现这个家伙? 谢谢。

编辑:

// this can be "Kommentar" or "Kommentera" in Swedish (2 different words) 
NSLocalizedString(@"Comment", @"Comment") 

我想什么有是:

NSLocalizedString(@"Comment_adj", @"Comment_adj") // En: Comment, Swe: Kommentar 
NSLocalizedString(@"Comment_verb", @"Comment_verb") // En: Comment, Swe: Kommentera 

现在是不是更清楚了吗?

+0

为什么向下票呢? – Carnal

+1

这很难理解你想要什么。你可以添加一些代码来举例说明你想要做什么吗? – joerick

+0

这正是为什么你不应该逐字翻译。 – borrrden

回答

3

解决此问题的方法是使用NSLocalizedStringFromTable(<#key#>, <#tbl#>, <#comment#>)为您的本地化字符串提供一些上下文。

例如:

NSLocalizedStringFromTable(@"Post", @"SubmitScreen", @"The button text for the post button on the submit screen"); 
NSLocalizedStringFromTable(@"Post", @"FenceDiagram", @"The label for the fence-post on the diagram of the fence"); 
+0

我正在使用本地化管理器应用程序来翻译我的单词。我生成带有起始字符的新本地化文件,但没有更新。他们有什么不寻常的我需要做伴侣吗? – Carnal

+0

阅读genstrings如何在这里工作:http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html并记住它解析源代码,所以我认为你的表名应该明确的,即@“表”而不是宏或函数调用。 – jhabbott