Reputation: 329
I'm getting an input string in language 1 and I'd like to find what key it corresponds to in my Localizable.strings
. Later I will use this key to retrieve its value in language 2.
How can I find a key by value?
Upvotes: 1
Views: 1609
Reputation: 997
let stringsPath = Bundle.main.path(forResource: "Localizable", ofType: "strings")
var dictionary = NSDictionary (contentsOfFile: stringsPath ?? "")
if let temp = dictionary?.allValues.filter({$0 as? String == "Your Value to be searched"}), temp.count > 0 {
print("nice found")
}
Check with above code.
Upvotes: 1