Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 11/iOS 13 Localization issue

I am having an issue with a grouped UITableView not getting localized in my settings controller since opening the project in Xcode 11 GM.

I use Localizable Strings and checked that all ObjectIds are correct. It worked in Xcode 10 and iOS 12 SDK. The weird things is that the localization works everywhere else in the app. It is just that one TableView.

Someone, any ideas? I even tried removing localization and adding it again.

like image 919
Fredrik Avatar asked Sep 12 '19 11:09

Fredrik


2 Answers

Update: The issue seems to be fixed in Xcode 11.2

--

This is now acknowledged as an issue in the release notes for Xcode 11.1 GM.

UITableViewCell labels in storyboards and XIB files do not use localized string values from the strings file at runtime. (52839404)

https://developer.apple.com/documentation/xcode_release_notes/xcode_11_1_release_notes/

like image 105
Fredrik Avatar answered Oct 01 '22 11:10

Fredrik


I faced the same issue with Xcode 11 GM. In my case, localization strings for title UILabel in static UITableViewCell are not applied.

Here is my workaround;

  1. Copy the labels' Object ID into Accessibility Identifier with the storyboard manually.
  2. Implement the following codes in the UITableViewDataSource class.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = super.tableView(tableView, cellForRowAt: indexPath)
    if let label = cell.textLabel, let id = label.accessibilityIdentifier, id.count > 0 {
        let key = id + ".text"
        let localizedString = NSLocalizedString(key, tableName: "Main", comment: "")
        if key != localizedString {
            label.text = localizedString
        }
    }
    return cell
}
like image 31
lavox Avatar answered Oct 01 '22 11:10

lavox