Localize a view within a storyboard using “User Defined Runtime Attributes”

前端 未结 3 1103
心在旅途
心在旅途 2021-01-04 08:43

I currently have a semi-automated way to localize my views. However, today I found an interesting section in IB, which seems to suggest that I can localize my views from wit

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 09:37

    The "user defined runtime attributes" are poorly documented. What I can remember from some book I read is, that UDRA was first implemented for MacOSX programming, so the Type "Localized String" could be a feature that is not fully supported for now in iOS.

    The funny thing is, that he is translating the strings in the storyboard previews (xCode 4.5.1), but later in the compiled iOS app, he is just injecting the key string.

    One solution I am thinking about right now, is to make a little helper class, that is checking the title/text strings of views on viewDidLoad for a keyword like "key", e.g. "XYControllerTitleKey", and then make NSLocalizedString-Method on that.

    UPDATE: It seems that in the meantime, there is a way to use the UDRAs:

    Storyboard/XIB and localization best practice

    And a tutorial as a result (link)

提交回复
热议问题