Internationalization of the big project

In our app code, we have a xcworkspace with some projects which build as frameworks or executable bundles. Also we have a main project of the app into this workspace. So all frameworks connected to the main as subprojects.

Some of these projects must be localized like a main project. But they have strings files with the same names. For example: InfoPlist.strings and Localizable.strings. And when we export them to localization from Xcode the same name files miss. There is only one into XLIFF file. May be the first of them. I don't know. So all localizable strings from NSLocalizedString() macros through workspace put to one file into the main project.

Is it possible to localize all our subprojects with the main project with the "Export for localization" tool of Xcode?

Replies

You have a few options.

First, from your subprojects, you can pass the bundle argument to NSLocalizedString and pass the correct bundle ID. That will ensure it doesn't try to use the app's main bundle.

You could simplify this by creating your own LocalizedString function/macro that automatically does this correctly.

Code Block
/// NSLocalizedString replacement for MyFramework.
func MyFrameworkLocalizedString(_ key: StaticString, comment: StaticString) -> String {
    return Bundle(identifier: "com.me.MyFramework")!.localizedString(forKey: "\(key)", value: nil, table: nil)
}


If you go this route and define your own function, you'll need to add that function name to the "Localized String Macro Names" build setting.

You can also specify custom table arguments to either NSLocalizedString or Bundle if you wish in order to customize the strings file that your string appears in, even within a single bundle.
Yes, thank you. I will try to rename Localizable.strings files in subprojects and use them as table arguments.