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")