I've created this mini translation of words from English to Spanish. The words read from a Localizable.strings and retrieves the words "cat" = "gato" using NSLocalizedString. At the moment it only read one word from the string, I would like yo know if there's any way to retrieve multiple words from Localizable.string, for example, "the" + "cat" = "el gato"
var myEnglishArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.translateTextField.delegate = self
picker.delegate = self
picker.dataSource = self
//var myEnglishArray = [String]()
if let URL = NSBundle.mainBundle().URLForResource("englishArray", withExtension: "plist") {
if let englishFromPlist = NSArray(contentsOfURL: URL) as? [String] {
for myEnglish in englishFromPlist {
myEnglishArray.append(myEnglish)
}
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func translateButtonTapped(sender: UIButton) {
let emptyString = self.translateTextField.text
if (emptyString!.isEmpty) {
print("please enter a word")
}
for transIndex in myEnglishArray.indices {
if myEnglishArray[transIndex] == emptyString!.lowercaseString {
//englishArray
//translateLabel.text = "\(spanishArray[transIndex])"
translateLabel.text = NSLocalizedString(emptyString!.lowercaseString, comment:"")
print(emptyString)
return
}
}
}