0
영어로 된 알파벳 순서로 이름이 지정된 간단한 표 셀을 사용했습니다. 나는 다른 언어로 모든 언어를 현지화 할 수 있었고 모든 것이 잘 작동합니다. 질문 : 지역화 된 이름을 사전 순으로 다른 언어로 입력하는 방법이나 명령이 있습니까?모든 현지화 가능 문자열의 알파벳 순서
import UIKit
var animals = [“A1”, “A2”, “A3”, “A4”, “A5”];
class TableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return animals.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCellController;
cell.textLabel?.font = UIFont(name: "Futura-Bold", size: 18);
cell.textLabel?.textColor = UIColor.black;
cell.textLabel?.text = NSLocalizedString(animals[indexPath.row], comment: "");
cell.smallBird.image = UIImage(named: animals[indexPath.row] + ".png");
return cell
}
}
지역화 문자열
/* Animals (EN) */
“A1" = “Cat”;
“A2" = “Dog”;
“A3" = “Owl”;
“A4" = “Leon”;
“A5" = “Tiger”;
FYI - Swift의 줄 끝에 세미콜론이 필요하지 않습니다. – rmaddy
@rmaddy하지만 OP는 문자열 지역화에 .strings 파일을 사용하고 있습니다.이 경우 세미콜론이 필요합니다. – Xcoder
@Xcoder 나는 문자열 파일이 아니라 스위프트 코드에 대해 이야기하고 있습니다. – rmaddy