【问题标题】:Localization of iOS Storyboard: UITextView texts are not localized?iOS Storyboard 的本地化:UITextView 文本未本地化?
【发布时间】:2015-04-20 05:41:21
【问题描述】:

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

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 方法会更好吗?
  • 没试过,不知道怎么做。你能告诉我怎么做吗?
  • 来自 Apple 的一些糟糕的错误?我也有这个问题。
  • 找到解决办法了吗?

标签: ios localization uitextview uistoryboard


【解决方案1】:

看起来这是a long-standing bug discussed here。

您可以尝试那里推荐的“将“Localizable Strings”更改为“Interface Builder Cocoa Touch XIB””方法,这似乎是一种奇怪的巫术魔法,但如果它有效,它就有效。否则,在运行时设置它似乎是必要的。

【讨论】:

  • 将其设置为 XIB 并返回字符串的方法不适用于 iOS 9。
  • 只是想说,这个“bug”还存在……很奇怪。经过这么长时间,它应该已经修复了。我猜开发人员有更好的事情要做,比如喝咖啡或吃苹果。
【解决方案2】:

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

【讨论】:

  • 令人惊讶的是,Apple 从未修复任何错误。今天是 2020 年 2 月,这个 bug 在 iOS 和 macOS 中仍然存在。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-13
  • 2011-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多