I'm about to try and internationalize my app by replacing all my hardcoded NSStrings with NSLocalizedString variants.
I've been playing around with a test app to see different workflows and I'm settled on using
- Unique keys for my strings rather than the string itself. ie. NSLocalizedString(@"MyTestString", ""), instead of NSLocalizedString(@"My Test String", "")
- XLIFF export, and import workflows that seem to work well, preserving localizations, accepting new updated strings etc
- I'd like to try and have a centralised file with all the NSLocalizedStrings listed so its easier to see any repeated strings that I may create scattered throughout my code.
All is well but I just think I'd like to use something like a strings.h to centralize all the NSLocalizedStrings calls themselves so I have one place to look through all the strings being used in code. I tried to achieve this at first by using #defines but sadly the genstrings or whatever workflow is now used for XLIFF export misses strings defined this way.
This question
Best practice using NSLocalizedString
Trod similar ground 3 years ago. At first #defines were considered and then in one of the comments it says
"I've talked with some other iOS devs recently, and they recommended the usage of static strings instead of macros, which makes sense."
I've been trying to get this working but am struggling, wondered if someone could explain how best to use static strings for this purpose? I create a static string in my header but i'm unable to assign strings to it there, or from a +method called during app initialisation later on. At this point it looks like i'd have to make them properties of a singleton class. Is there a simpler way to get this centralised localized string look up table?
Cheers