如何快速本地化故事板? [英] How to quickly localize storyboard on the fly?

查看:96
本文介绍了如何快速本地化故事板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Swift 3和Xcode 8.1本地化我的应用。

I am trying to localize my app using Swift 3 and Xcode 8.1.

我正在尝试使用两个storyboard(main.strings(德语))本地化应用程序并以编程方式使用NSLocalizedString

I am trying to localze the app using both storyboard(main.strings(German)) and programatically using "NSLocalizedString".

我可以使用NSLocalizedString以编程方式进行本地化使用以下代码

I am able to localize programatically using "NSLocalizedString" using following code

func localized(lang:String) ->String {

        let path = Bundle.main.path(forResource: lang, ofType: "lproj")
        let bundle = Bundle(path: path!)

        return NSLocalizedString(self, tableName:  nil, bundle: bundle!, value: "", comment: "")
    }

但是我坚持使用故事板中定义的本地化。我在main.strings(德语)中定义了本地化字符串。

But I am stuck with the localizations which are defined in storyboard. I have defined localised string in main.strings(German).

/* Class = "IBUILabel"; text = "Date :"; ObjectID = "0sh-CK-26C"; */
"0sh-CK-26C.text" = "Datum :";

有没有办法在运行时本地化故事板?

Is there any way to localize the storyboard on run time?

推荐答案

我认为,本地化故事板的最佳方法是 -
您应该先用本地语言完成设计工作,然后将故事板本地化为所需的语言。然后导出.xliff文件并替换所需语言的所有文本。然后再次将.xliff文件导入到您的项目中。
你完成了......!

I think, the best way to localize a Storyboard is- You should first finish the design work in local language and then localize your storyboard in the desired language. Then export .xliff file and replace all the texts in the desired language. And then again import the .xliff file to your project. And you are done...!

这篇关于如何快速本地化故事板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆