Associate InfoPlist.strings to targets
From the Apple Developer Technical Notes:
If your app supports localization, be sure to localize CFBundleDisplayName by adding it to all your language-specific InfoPlist.strings files. Furthermore, be sure to use a name that complies with the App Review Guidelines for your app.
Prerequisites
I am assuming you already have multiple targets.
I am also assuming you already have an InfoPlist.strings
file. If your do not, code > File > File... > Resource > Strings File > Next > Save As: InfoPlist > Base.lproj > Target: the english target > Create
Ensure you have enabled this in your Info.plist
:
<key>LSHasLocalizedDisplayName</key>
<true/>
Step by step
- In Project Navigator, select
InfoPlist.strings
.
- In File Inspector > Localization, select all the languages. This will create and/or copy said
InfoPlist.strings
into their respective locations.
- Would you want to add languages, you achieve this in Project Navigator > project > Project & Target List > Project > Info > Localizations > +. Again, keep Use Base Internationalization.
- Unfortunately, when you execute step 2., Xcode does all the magic for you. It is worth noting that in versions of Xcode where that magic did not happen, you had to do the associations by hand. Step 5. is about reverting the magic.
- Remove InfoPlist.strings from the Project Navigator. Of course, only Remove References when prompted.
- In the Finder, locate
en.lproj
, drag it onto your Project Navigator, pick Create Groups, add to target your English, or Base target, Finish
- Repeat step 6 with
de.lproj
, fr.lproj
, each time dragging the entire .lproj
from the Finder, and associating with the appropriate target.
- Some
.lproj
may contain other localized files for which you want to enjoy the magic of step 3. Simply remove their references.
- You are done.
The final setup, for say the German language, will look like this in the File Inspector:
References:
Share localization across targets:
This is the general method to achieving localization. See https://mcmap.net/q/931129/-different-storyboard-localization-per-target.
Specific localization to specific targets:
This is only useful if you want to explicitly control which languages go into which target. See https://mcmap.net/q/931129/-different-storyboard-localization-per-target.