Localized String with Interface Builder User Defined Runtime Attributes

折月煮酒 提交于 2019-12-10 13:32:46

问题


I am currently trying to create a localized accessibilityLabel in the storyboard (I am trying to avoid doing it programatically). It seems that whenever I use the Localized String option, the accessibilityLabels ends up being set to the localized string key that I have provided rather than the string itself. Does anyone have the solution to this problem? Any help would be greatly appreciated.


回答1:


I guess you expect the localized string to be taken from Localizable.strings. The "Localized String" type doesn't work this way, it's just a marker to indicate that the value of the user defined runtime attribute will participate in the localization process when you use base localization. Please take a look at https://stackoverflow.com/a/24527990/2876231 for a lengthier explanation.




回答2:


The attribute type needs to be Localizable String, and then you'd translate it in the .strings file using the following property:

"KLc-fp-ZVK.ibExternalUserDefinedRuntimeAttributesLocalizableStrings[0]" = "¡Hola!";

Unfortunately, it doesn't seem to work with a named attribute, but only with the long property above.

(Based on Andrew's answer here: Localize a view within a storyboard using "User Defined Runtime Attributes")



来源:https://stackoverflow.com/questions/21870950/localized-string-with-interface-builder-user-defined-runtime-attributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!