Localization for multiple targets

I have one project where I have XYZ scheme and target. I have Localizable.string under XYZ target for localization. I want to create a ABC target (duplicate of XYZ) and set custom language support for it. Let's say I have english, french and german for XYZ, I want hindi, japanese and chinese for ABC. I did the below steps

  1. I went to Manage scheme and duplicated the XYZ (duplicate scheme = ABC).
  2. I added new localization file only for ABC (LocalizationForABC.string) and made sure those reflect in File Inspector -> Target (only ABC selected) and also checked in Build Phases -> Copy Bundle Resources (LocalizationABC exists).

When I run the ABC target under let's say french, it works fine but when I build the project ABC, and remove french from XYZ, ABC is broken and it only runs in english. Am I missing something here ?

Let me make sure I understand your configuration correctly:

  • You have an ABC and XYZ target
  • Each target has a group of Localizable.strings files (one for each supported language in a .lproj directory)
  • In the File Inspector, a different subset of languages is selected for Localizable.strings in ABC vs. XYZ
  • Are the underlying Localizable.strings files different on disk between the two targets, or do both file references point to the same underlying files?

Is this the config that is not working for you at runtime?

The first 2 points are as you stated. For the third point, in ABC I have Localizable.strings and for XYZ I have XYZLocalizable.strings. In the build phases -> copy bundle resources for ABC I have Localizable.strings and for XYZ I have XYZLocalizable.strings.

To answer your question, yes I do have different files (Localizablle.strings and XYZLocalization.strings). How do I check the references point ?

The File Inspector should show which files are pointed to by file references in Xcode.

However, if one of the files is not named "Localizable.strings", then when looking up the localizable strings in source code you'll need to pass a custom table name.

For example

String(localized: "my_key", table: "XYZLocalizable")

Or you could name both files "Localizable.strings" and then you would not need to specify a custom table name in code.

Localization for multiple targets
 
 
Q