This task provides some assistance for localizers of strings files and nib files.
Localizing Strings Files
Localizing Nib Files
Strings files generated by genstrings
have content that looks like this:
/* Comment */ |
"key" = "key"; |
That is, the value string is the same as the key string.
Translators should type the localized version of the key string in place of the second string. Use the comment, if necessary, to understand the context in which the string is displayed to the user:
/* Comment */ |
"key" = "French version of the key"; |
If a string contains multiple variable arguments, you can change the order of the arguments by using the “$” modifier plus the argument number
/* Message in alert panel when something fails */ |
"Oh %@! %@ failed!" = "%2$@ blah blah, %1$@ oh!"; |
Just as in C, some characters must be prefixed with a backslash to be included in the string properly. These characters include double-quote, backslash, and carriage return. You can also specify carriage returns with “\n
”:
"File \"%@\" cannot be opened" = " ... "; |
"Type \"OK\" when done" = " ... "; |
Strings can include arbitrary Unicode characters with “\U
” followed by up to four hexadecimal digits denoting the Unicode character; for instance, space, which is hexadecimal 20, is represented as “\U0020
”. This option is useful if strings must include Unicode characters which cannot be typed for some reason.
Strings files are best saved in Unicode format. This allows them to be encoding-independent, and simplifies the encoding to use when an application loads strings files. The TextEdit application can save in Unicode format. The encoding can be selected either from the Save panel, or as a general preference in TextEdit's Preferences panel.
For more information about strings files, see “Strings Files.”
You use Interface Builder to create nib files, and you should use Interface Builder to localize nib files. Typically you open all of the nib files in a language.lproj
directory, localize all the strings, change the sizes of UI elements if necessary, and save the nib files. There are a few things to watch out for:
Objects in a nib file typically have connections between them that should not be broken. You should lock all connections (an option in the Preferences panel of Interface Builder) before editing the nibs.
Panels and windows usually have minimum or maximum sizes that are specified through the inspector panel. If you must make a panel or window wider for a given language, it's likely that the minimum size also needs to be modified.
Some UI objects support “tool tips” – little blurbs that come up when the user hovers on the UI element for a short while. You enter these strings in the inspector, where they should also be localized.
© 2003, 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)