NSLocalizedString Key

Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work

  • Identifier: nslocalizedstring_key
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    severity warning

Non Triggering Examples

NSLocalizedString("key", comment: "")
NSLocalizedString("key" + "2", comment: "")
NSLocalizedString("key", comment: "comment")
NSLocalizedString("This is a multi-" +
    "line string", comment: "")
let format = NSLocalizedString("%@, %@.", comment: "Accessibility label for a post in the post list." +
" The parameters are the title, and date respectively." +
" For example, "Let it Go, 1 hour ago."")

Triggering Examples

NSLocalizedString(method(), comment: "")
NSLocalizedString("key_\(param)", comment: "")
NSLocalizedString("key", comment: "comment with \(param)")
NSLocalizedString("key_\(param)", comment: method())