IOS/iPhone: Nested Localizable.strings Files?
Two alternatives:
Use custom wrapper functions around
NSLocalizedString
that do your hierarchical lookup for you, and then fall back to theNSLocalizedString
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.