Internationalization and localization
Internationalization (i18n) refers to the process of extracting strings from source code and presenting them as properties with a set of values.
Localization (l10n) refers to the process of translating values of these properties into target languages.
AppCode provides helpful features that simplify working on software internationalization and localization issues. These features include advanced editing assistance for strings files, intention actions and quick fixes related to internationalization issues.
In AppCode projects, strings that need to be localized are stored in text files with the .strings extension — strings files. These files contain pairs of keys and values that can be accessed and rendered in the UI.
In a project, there is at least one strings file for each locale (you can add new locales in Xcode). The strings files reside in the .lproj directories, for example, en.lproj, es.lproj. In the Project view of the Project tool window, localizable files are shown as groups of language-specific resources.
|Project view||Files view|
Extract values to strings file
In the editor, place the caret at the string literal that you want to localize.
Press ⌥⏎, select Localize the string, and press ⏎.
AppCode will replace the string literal with the
The string will be added to the Localizable.string file for all available locales. If there is no file with such name in your project, a dialog opens where you can choose the location for Localizable.string, and AppCode will add this file to the project.
Provide localization for NSLocalizedString
To add localization for a string used in the
NSLocalizedString macro, do the following:
Place the caret at the first parameter of the
Press ⌥⏎, select Provide localization for "<string>", and press ⏎.
The string will be added to the Localizable.string file. If there is no file with such name in your project, a dialog opens where you can choose the location of Localizable.string, and AppCode will add this file to the project.
Delete unused localized strings
Unused strings are grayed out in the strings file. To delete such strings, do the following:
Place the caret at the grayed out string.
Press ⌥⏎, select Safe deleted localized string '<string>', and press ⏎.
In the dialog that opens, choose if you want to search for the string usages in comments and text contents. If any usages are found there, the Find tool window will appear. Check the search results and click Do Refactor to finish the operation.
Change application language and region
You can change the language and region of your application at runtime: