I am using unlocalized strings and getting below warning
User-facing text should use localized string macro
How to suppress this warning ?
The Localization IdentifierAn unique identifier is attached to each translated string called the "Localization Identifier". It is used to search the dictionaries and locate the value of the string in different languages.
NSLocalizedString is a Foundation macro that returns a localized version of a string. It has two arguments: key , which uniquely identifies the string to be localized, and comment , a string that is used to provide sufficient context for accurate translation.
From clang documentation:
you can suppress the analyzer warnings (and document your intent) with a function that just returns its input but is annotated to return a localized string:
__attribute__((annotate("returns_localized_nsstring"))) static inline NSString *LocalizationNotNeeded(NSString *s) { return s; } [field setStringValue:LocalizationNotNeeded(@"Debug")];
Some projects may also find it useful to use NSLocalizedString but add "DNL" or "Do Not Localize" to the string contents
in the project Build Settings: "Static Analyzer - Issues - Apple APIs" set "Missing Localizability" to No
also make sure to not have any Localizations, otherwise will xcode 9 will warn you to turn on "Missing Localizability" analyzer warnings again.
this was trickier for me, i had to open the project file (project.pbxproj) with a text editor and manually empty the list of "knownRegions" otherwise they would not stay deleted
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