A quick tip to help track down strings that are missing from a localization.
When you are localizing an application it is easy to miss a string. Perhaps you forgot to update/regenerate the strings file after a change to the interface or include the latest localizations from the translator. Either way, if you do not spot the problem before shipping the result is an ugly experience for your users.
Launch Argument - NSShowNonLocalizedStrings
I have written about using launch arguments to make it easier to test different localizations. There is another launch argument you can add that will also detect strings that you have not yet localized for that language. From the Apple Resource Programming Guide:
- The NSShowNonLocalizedStrings user default locates strings that were meant to be localized but could not be found in the application’s existing strings files.
You can pass this argument, with a value of “YES”, to an application at launch time by adding it to the Xcode scheme. From the Xcode Product menu use Scheme > Edit Scheme and for the Run phase use the Arguments tab. Make sure you include the leading hypen “-”. In the screenshot below I also have the launch argument to run the application using the Spanish localization.
With the launch argument set, running in a locale with a missing localization for a string writes an error to the debug console:
Localizable string “Hello World” not found in strings table “Localizable” of bundle CFBundle
This will also work if you have strings in a storyboard that you have not localized though the error message is not so helpful in telling you which string is missing:
Localizable string “So6-fv-SWh.text” not found in strings table “Main” of bundle CFBundle
Xcode Options (Update 22-Dec-2015)
Thanks to the many people who have pointed out that Xcode 7 has options to directly enable localization debugging and setting the application language/region. The syntax for the launch arguments is tricky so this makes it much easier. In the scheme editor take a look at the Options tab. In the following screenshot I have “Show non-localized strings” enabled with the application language set to “Spanish”: