简体   繁体   English

使用XIB(Interface Builder)在iOS中进行本地化

[英]Localization in iOS with XIB (Interface Builder)

I have searched now quite a bit on Stackoverflow for an answer, but I can't seem to find an adequate one. 我已经在Stackoverflow上搜索了很多答案,但是似乎找不到合适的答案。

So, I am localizing an App with XCode. 因此,我正在使用XCode本地化应用程序。 Everything works fine, I have localized a storyboard and everything. 一切正常,我已经将情节提要和所有内容本地化。 The last part which needs to be localized are the labels and buttons in XIB Files. 需要本地化的最后一部分是XIB文件中的标签和按钮。 Here I have the following Problem: 这里我有以下问题:

XCode Offers me to create localized Xib Files for every language or to create strings files. XCode让我可以为每种语言创建本地化的Xib文件或创建字符串文件。 Both options are fine with me, but none seems to work. 两种选择对我来说都很好,但似乎都没有用。 One answer to a similar question stated that this does not work my design. 一个类似问题的答案表明,这不适用于我的设计。 If so, why does XCode give me the option to do it in the first place? 如果是这样,为什么XCode首先让我选择这样做? And, what is a good and easy solution for this? 而且,对此有什么好的简单的解决方案呢?

And I am using Swift, not sure if that really matters, I just thought I mention it. 我正在使用Swift,不确定那是否真的很重要,我只是以为我提到了。

There is a known issue with recent versions of Xcode where the simulator would not correctly pass the language information to the app, so it seemed as if localization was not working. Xcode的最新版本存在一个已知问题,其中模拟器无法正确将语言信息传递给应用程序,因此本地化似乎不起作用。 If that is your problem, there are two workarounds: 如果这是您的问题,则有两种解决方法:

  1. try your app on a device and confirm switching the language brings up your localized strings. 在设备上尝试使用您的应用,并确认切换语言会显示本地化字符串。
  2. force the language via your build scheme (Product => Scheme => Edit Scheme... => Run => Application Language) 通过您的构建方案强制使用该语言(产品=>方案=>编辑方案... =>运行=>应用程序语言)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM