Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localized String with Interface Builder User Defined Runtime Attributes

Storyboard

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.

like image 799
user1927638 Avatar asked Feb 19 '14 04:02

user1927638


2 Answers

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.

like image 61
José González Avatar answered Sep 20 '22 16:09

José González


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

like image 37
dAngelov Avatar answered Sep 17 '22 16:09

dAngelov