【发布时间】:2018-06-21 07:01:36
【问题描述】:
我有 7 个标签。我能够本地化所有 7 个标签标题的文本 但是当应用程序启动时,默认情况下仅显示 4 个选项卡,其中“更多”选项卡作为第 5 个选项卡。我想本地化“更多”的文本。我该怎么做?
【问题讨论】:
我有 7 个标签。我能够本地化所有 7 个标签标题的文本 但是当应用程序启动时,默认情况下仅显示 4 个选项卡,其中“更多”选项卡作为第 5 个选项卡。我想本地化“更多”的文本。我该怎么做?
【问题讨论】:
系统提供的“更多”标签栏项目上的标签会自动本地化...如果您已将InfoPlist.strings 本地化为用户的语言选择。
我使用“选项卡式应用程序”模板创建了一个新项目,并为其提供了几个额外的 FirstViewController 实例,以使其显示“更多”选项卡。我在模拟器中运行它。当我将模拟器的语言从英语更改为西班牙语时,它没有翻译“更多”标签。
然后我在项目中单击InfoPlist.strings,在文件检查器中(在 Xcode 窗口的右侧)中,我添加了法语作为本地化。模拟器中的“更多”标签仍然是英语(尽管我的语言仍然设置为西班牙语)。然后我把语言改成法语,“More”标签被翻译成“Autre”。
【讨论】:
您可以为 more tabBarItem 和 moreTableViewController 本身设置本地化字符串!
//Here you can set the tabBarItem title and also the images when active and not active
moreNavigationController.viewControllers[0].tabBarItem=UITabBarItem(title: String.localizeStringForKey("More"), image: UIImage(named:"more_30x30")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal), selectedImage: UIImage(named:"more_active_30x30")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal))
// Here you can set the title of the moreTableViewController
moreNavigationController.navigationBar.topItem?.title = String.localizeStringForKey("More")
【讨论】: