I need to print the keys of Localizable.strings in my App, instead of their values (for a debugging purpose). Is there a fast way to override the NSLocalizedString() method or redefine the macro, something like:
#define NSLocalizedString(key, comment) NSLocalizedString(key, key)
One option would be to export your app for localizations via Product Menu > Export Localizations within Xcode, then save the xcloc file to your Desktop.
After which you could use a python script to parse the inner xliff (xml) to find the file elements with
originalattributes which containLocalizable.stringsand print thetrans-unit'ssourceelement text within the body of them. Here's an example of a python script which should do it localizationKeys.py:Which you could then use as follows:
Or if you'd prefer to print to to a file instead
This could almost definitely be more concise using
xpathinstead, but this is just what I came up with quickly.