I'm creating an app that will have a number of variants.
These variants will be controlled by a few strings in multiple Localizable.strings files.
However, 90% of the strings will remain the same.
I'd like to have it so that each of the unique Localizable.strings files imports the "master" one, so that I don't have to go through each of the app variant files when I want to change a common string.
Is this possible?
Two alternatives:
Use custom wrapper functions around NSLocalizedString
that do your hierarchical lookup for you, and then fall back to the NSLocalizedString
mechanism for the default case.
I previously wrote an answer about how to do this: Can .strings resource files be added at runtime?
Use multiple .strings files per language. By default things are looked up in "Localizable.strings", but the NSLocalizedStringFromTable()
function allows you to specify a custom "table" name. So if you passed in "Configuration" as the table name, it would look things up in the "Configuration.strings" file.
I worked on an app that did this. We had two different .strings files. One controlled the branding settings (what name to use, what images to use, what servers to use, etc), and the other contained all of the actual translated strings. There would only be a single copy of the branding information in the app bundle, and we chose the correct variant to use at compile time with some custom scripts. It worked really really well.