Export localizations — Workflow for multiple targets that share strings?

I am trying to localize an iOS app that also ships an App Clip. The main app and the App Clip share many (but not all) of the same localizable strings.

Using Product -> Export Localizations..., I can generate a .xcloc file that contains all the localizable strings found for each of these two targets. However this results in a large number of strings being duplicated.

For example, if I have a file with Text("bla bla bla") that is included in both the main app and the app clip, the string bla bla bla appears twice in the xcloc: once under MyApp and once under MyAppAppClip

What is the recommend workflow when you need to localize multiple targets that share strings? Ideally I'd like to be able to send a simple set of files off to the translation and then import the results without having to manually copy arounds strings. Do I need to split all the shared code out to a shared package instead of just including shared code files in both targets?

Answered by Developer Tools Engineer in 702714022

You can share code between your targets and have them also share a single Localizable.strings file. To do this, Xcode needs to know how you want to share the file. Can you try adding an empty en.lproj/Localizable.strings file to both targets before exporting for localization?

Accepted Answer

You can share code between your targets and have them also share a single Localizable.strings file. To do this, Xcode needs to know how you want to share the file. Can you try adding an empty en.lproj/Localizable.strings file to both targets before exporting for localization?

Thanks! That worked. Just to be super explicit about what I did in case any one else runs into this problem:

  1. Add a single new Localizable.strings file that is included in both the main app and the app clip
  2. Make sure that file is marked as localizable
  3. Run Export localizations again

In my case, the resulting xcloc file now looks like:

MainApp/
    InfoPlist

MainAppAppClip/
    InfoPlist

Shared/
    Localizable

Localizable contains all the strings from both targets

Export localizations — Workflow for multiple targets that share strings?
 
 
Q