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.
Unfortunately, Apple doesn't support that for its Localizable.strings
files.
You could mimic that feature through a custom Ruby or Python script or just a Bash script using sed
; the script could take the root .strings
file and copy the contents into each variant's .strings
file. It could even be a custom build step in Xcode.
I'm not sure of what you want but if you just want to translate a few strings you could.
You can just translate a part of these strings, if there is no translation, ios will select the strings in the application language and display it. So the Localizable.strings in the application language could be consider like the master one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With