NSLocalizedString

NSLocalizedString provides string localization in “compile-once / run everywhere” fashion, replacing all localized strings with their respective translation according to the string tables of the user settings. But even if you’re not going to localize your app to any other markets, NSLocalizedString does wonders with respect to copy writing & editing.

nshipster.com/nslocalizedstring/

NSLocalizedString is a macro in Foundation that gives a localised version of a string. It takes a key to find the string and a comment to help translators. It finds the right translation from the user's language settings. Even if you do not plan to translate your app, it helps you check all user-facing strings.

For format strings, use it as the format and add comments for context, like "%@'s Profile" with "{User First Name}'s Profile".

There are versions like NSLocalizedStringFromTable for specific files or bundles. Translations go in Localizable.strings files per language, made with genstrings from your code.

Do not split strings into parts; localise full sentences to keep meaning and grammar right. Always wrap strings users see in NSLocalizedString. It shows care in your code and makes later changes easy.


Category:

Year: