2017-09-26 92 views
0

我升级到iOS 11并将Xcode版本更改为9时出现问题。
当我选择“缅甸语言”时,“设置”菜单文本不会转换,但是休息菜单文本被翻译成缅甸语。
iOS 11中的本地化,swift 4

var TableArray = [["Home","Buy", "Watch Later"],["Notification","Settings","User Guide"]] 

菜单文本放在数组中,并位于表视图单元格中。

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCell(withIdentifier: TableArray[indexPath.section][indexPath.row], for: indexPath) as UITableViewCell 
    cell.imageView?.image = menuIconImage[indexPath.section][indexPath.row] 
    cell.textLabel?.text = NSLocalizedString(TableArray[indexPath.section][indexPath.row], comment: "") 
    cell.textLabel?.font = UIFont(name: "Tharlon", size: 17) 
    cell.selectionStyle = UITableViewCellSelectionStyle.blue 
    tableView.rowHeight = 56.0; 

    return cell 

} 

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
    prefs.setValue(false, forKey: "FLAG") 
    prefs.setValue(true, forKey: "DRAWER") 
    debugPrint("Click LogIn") 

    let cell = tableView.dequeueReusableCell(withIdentifier: TableArray[indexPath.section][indexPath.row], for: indexPath) as UITableViewCell 
    cell.imageView?.image = menuIconImage[indexPath.section][indexPath.row] 

    cell.textLabel?.font = UIFont(name: "Tharlon", size: 17) 

    cell.textLabel?.text = NSLocalizedString(TableArray[indexPath.section][indexPath.row], comment: "") 
} 

不过我想,所有的文本修改为“缅甸”,除了“设置”文本。因此,我在表格函数中再次添加了以下代码,但它不能正常工作

if (cell.textLabel?.text == "Settings") { 
     cell.textLabel?.text = NSLocalizedString(TableArray[indexPath.section][indexPath.row], comment: "") 
     cell.textLabel?.font = UIFont(name: "Tharlon", size: 17) 
    } 


谁能帮助我吗?自从最近2天以来,我仍然在为此寻找解决方案。 :(

回答

0
if Language.currentLanguage() == "ar" 
{ 
    cell.textLabel?.textAlignment = .right 
} 
else 
{ 
    cell.textLabel?.textAlignment = .left 
} 

这个工作跟我