如何本地化iOS故事板 [英] How to localize an iOS storyboard

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

问题描述

我有一个带有一些观点的iPhone故事板。例如,导航项目标题名为新闻,应该翻译为其他语言。

I've a iPhone storyboard with some views. For instance a navigation items title is named News, which should be translated for other languages.

当我添加一个新的本地化到我的故事板,它创建了我当前的新语言故事板的副本。在这里我可以更改导航项的标题,但对我来说它似乎没有用。如果我的故事板包含100个视图并且我需要支持10种语言怎么办?如果我需要在原始故事板中更改某些内容,我必须对所有语言进行相同的更改。这似乎很奇怪。在哪些情况下这可能有用吗?

When I add a new localization to my storyboard, it created a duplicate of my current storyboard for the new language. Here I can change the title for the navigation item, but for me it does not seems very useful. What if my storyboard contains 100 views and I need to support 10 languages? If I need to change something in my original storyboard, I have to make the same changes for all languages. That's seems very odd. In which situations can this be useful?

我该怎么做?我应该只有英文故事板并使用 NSLocalizedString 手动翻译ViewController中的每个元素吗?

What can I do instead? Should I have only the english storyboard and manually translate each element in the ViewController using NSLocalizedString?

推荐答案

您可以通过更改代码中UI元素的标题来进行本地化:

You can do the localization by changing the titles of the UI elements in code:

self.title = NSLocalizedString("News", nil);

如果你想用荷兰语本地化你的应用程序,你可以用 Dutch.lproj / Localizable.strings

If you want to localize your app in Dutch for example, you would have this in Dutch.lproj/Localizable.strings:

"News" = "Nieuws";

然后,您可以为每个UI元素和语言执行此操作。

You can then do this for every UI element and language.

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

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