【问题标题】:ios - how to localize the text for "more" in tab barios - 如何本地化标签栏中“更多”的文本
【发布时间】:2018-06-21 07:01:36
【问题描述】:

我有 7 个标签。我能够本地化所有 7 个标签标题的文本 但是当应用程序启动时,默认情况下仅显示 4 个选项卡,其中“更多”选项卡作为第 5 个选项卡。我想本地化“更多”的文本。我该怎么做?

【问题讨论】:

    标签: ios tabs


    【解决方案1】:

    系统提供的“更多”标签栏项目上的标签会自动本地化...如果您已将InfoPlist.strings 本地化为用户的语言选择。

    我使用“选项卡式应用程序”模板创建了一个新项目,并为其提供了几个额外的 FirstViewController 实例,以使其显示“更多”选项卡。我在模拟器中运行它。当我将模拟器的语言从英语更改为西班牙语时,它没有翻译“更多”标签。

    然后我在项目中单击InfoPlist.strings,在文件检查器中(在 Xcode 窗口的右侧)中,我添加了法语作为本地化。模拟器中的“更多”标签仍然是英语(尽管我的语言仍然设置为西班牙语)。然后我把语言改成法语,“More”标签被翻译成“Autre”。

    【讨论】:

    • 非常感谢,我明白了。但是在 Info.plist 文件中,你能给我实际的文本吗(只考虑法语本地化)
    • 我可以将名称从 more 更改为其他名称吗?
    • 这里是如何为更多标签栏项目和 moreTableViewController 本身设置本地化字符串 moreNavigationController.viewControllers[0].tabBarItem=UITabBarItem(title: String.localizeStringForKey("More"), image: UIImage( named:"more_active_30x30")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal), selectedImage: UIImage(named:"more_30x30")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)) moreNavigationController.navigationBar.topItem?.title = String.localizeStringForKey("More" )
    【解决方案2】:

    您可以为 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")
    

    【讨论】:

      猜你喜欢
      • 2013-01-18
      • 1970-01-01
      • 2021-02-17
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      • 2013-09-12
      相关资源
      最近更新 更多