1

I'd like to check whether an array of localised strings in any localisation contains a string.

let myItem = "thisItem"

let items: [String] = [/*several strings*/]
var localisedItems: [String] {
  return items.map { NSLocalizedString($0, comment:"") }
}

for item in localisedItems where item.lowercased() == myItem.lowercase() {
  print("myItem found.")
}

Is there a way to loop through all localisations/languages?

Background: I want to avoid the user entering an item name in a UITextField that is already in use by the default items in any localisation (as the user may switch the language).

nontomatic
  • 2,003
  • 2
  • 24
  • 38

0 Answers0