Reputation: 2538
I'm currently trying to localize my iOS app into French. For some reason my keys aren't being properly recognized. My .strings
french file looks like this:
"START_FLIGHT" = "Démarrez";
"STOP_FLIGHT" = "Arrêtez";
But when I call:
let title = NSLocalizedString("STOP_FLIGHT", comment: "Stop Flight")
StartandStop.setTitle(title, forState: UIControlState.Normal)
The title of the button is changed to STOP_FLIGHT
, where I intended the title to become Arrêtez
. What have I got wrong?
Upvotes: 0
Views: 346
Reputation: 1296
I've figured out :)
You have to specify the tableName (which is the Storyboard name, in most cases), like these, either works
let titleStr = NSBundle.mainBundle().localizedStringForKey("STOP_FLIGHT", value: "default stop flight", table:"Main")
let anotherTitle = NSLocalizedString("STOP_FLIGHT", tableName: "Main", comment: "Comment")
Upvotes: 1
Reputation: 2538
So it turns out that localized string files can only be of the form Localizable.strings
whereas I had named mine Localization.strings
.
Upvotes: 0