ThaDon
ThaDon

Reputation: 8068

Can localization be done only through Code and not directly in Interface Builder?

Does IB not allow one to specify a localized key for components that display text instead of hardcoding the value? For instance, if you want a UILabel to display internationalized text is the only way to do this via code? Seems like such a PITA to have to set all your label text in code when you have a nice WYSIWYG editor like IB. I think I had this feature back in VB5!

Upvotes: 0

Views: 207

Answers (2)

v1Axvw
v1Axvw

Reputation: 3054

The normal way in Cocoa/AppKit is to localize the files you want to exist in different languages. But probably the only files you want make localized are your nib/xib files and your strings files.

Clafou has explained how you localize the nib files.

The strings files are files which contain key-value pairs. By calling functions like NSLocalizedString you can query them with the key you've set.

Apple has documented all these features.
Nib files
Strings files

Upvotes: 1

Clafou
Clafou

Reputation: 15400

You actually don't normally need to write any code to localize your Interface Builder user interface (Xibs). What you do is create localized versions of these Xibs, with the help of XCode. In your XCode project, select a Xib, open the File Inspector (it's in the Utilities panel) and you'll see a Localization section in there. Click the + button and XCode will create a version for the language of your choice, which you can then localize by translating the text as well as resizing UI elements or do anything else you like.

Upvotes: 3

Related Questions