iOS故事板的本地化:UITextView文本没有本地化?

19

我有一个基于故事板的应用程序,从德语本地化到英语。

大多数 UI 中的字符串都正确地从 Main.strings 文件中提取,但 UITextViews 中的所有文本除外,尽管它们出现在 Main.strings 文件中:

/* Class = "IBUITextView"; text = "Die Futtermenge kann bei Hunden ab 12 Monaten anhand des Schiebreglers von 2% auf 5% des Körpergewichts verstellt werden. Als Standart empfehlen wir 2% Futter vom Körpergewicht Ihres Hundes. Je nach Aktivität kann das abweichen. Wenn Sie bereits eine hohe Menge an Futter geben und Sie der Meinung sind, es ist nicht ausreichend, erhöhen Sie die Fettmenge im Futter. Mehr unter den Fragen & Antworten.\n \nFür Welpen und Junghunde gilt:\nWelpen 8 - 20 Woche: 7%\nJunghunde 21 - 35 Woche: 6%\nJunghunde 36 - 52 Woche: 5%"; ObjectID = "TAc-yh-nWQ"; */
"TAc-yh-nWQ.text" = "As of 12 months of age, you can use the slide ruler to adjust the food amount for dogs from 2% to 5% of body weight. As a baseline, we recommend 2% of your dog's weight to determine the amount of food. It will vary depending on activity. If you are already giving your dog a lot of food and you feel it is not sufficient, increase the fat content of the food. More information can be found in the FAQ section.\n \nFor puppies and young dogs:\nPuppies 8 - 20 weeks: 7%\nYoung dogs 21 - 35 weeks: 6%\nYoung dogs 36 - 52 weeks: 5%";
/* Class = "IBUILabel"; text = "Getreide:"; ObjectID = "VMF-xs-WfF"; */
"VMF-xs-WfF.text" = "Grains:";
/* Class = "IBUIButton"; normalTitle = "Gewicht aktualisieren..."; ObjectID = "WpP-c7-ipY"; */
"WpP-c7-ipY.normalTitle" = "Update weight...";

我的 Main.strings 出了问题吗?上面是摘录内容。

如果您使用_.xliff_方法,它是否能更好地工作? - matt
我还没有尝试过那个,我不知道怎么做。你能告诉我吗? - mrd
1
苹果的一些糟糕的 bug?我也遇到了这个问题。 - TPG
你找到解决方案了吗? - H S W
2个回答

8

看起来这是一个长期存在的错误,在这里讨论

你可以尝试那里推荐的“将“本地化字符串”更改为“Interface Builder Cocoa Touch XIB””方法,这似乎是一种奇怪的巫术,但如果它有效,那就行了。否则,似乎需要在运行时进行设置。


将其设置为XIB,然后转换为字符串的方法在iOS 9上不起作用。 - Duck
14
我想说,这个“漏洞”仍然存在……非常奇怪。毕竟这么长时间应该已经被修复了。我猜开发人员有更好的事情要做,比如喝咖啡或吃苹果。 - Luftbaum

6

我的解决方案是使用Localizable.strings文件通过代码本地化文本视图。


8
苹果从来不修补任何错误真是令人惊讶。今天是2020年2月,该漏洞在iOS和macOS系统中仍然存在。 - Duck

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接