.xib 文件中的多语言标签更改。
我必须将应用程序开发为四(4)种语言(英语、法语、斜体、西班牙语)。
因此,为此我想知道是否有任何方法可以仅使用顶部栏中的一(1)个 .xib 文件
来显示不同的语言数据。
示例:
我有Setting.xib(.xib文件) 其中有四个标签 查看部分并在其顶部栏中 Nib 文件我想更改标签 根据设置的语言命名 使用 One &只有一个 Nib 文件。
所以,请给我适当的解决方案。
这将花费更少的加载时间。
I have to develop the application into Four(4) languages (English, French, Italic, Spanish).
So, for that I want to know is there any way to display different language data using only one(1) .xib file
in the top bar.
Example:
I have the Setting.xib (.xib file) in
which there are four labels in the
view part and in the top bar of that
Nib file I want to change the label
names according to the set language
using One & Only one Nib file.
So, please give me the appropriate solution.
Which will take less time for the loading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我不明白为什么你不能在设置标签文本时简单地使用
NSLocalizedString
,它完全按照你想要的方式执行,根据设备的语言加载适当版本的文本。不管怎样,我认为你可以在这里找到一些有用的东西。
我实际上做了类似的事情,使用六种语言,只有一个 Nib,但就我而言,我可以在应用程序内部更改语言,所以我需要能够强制告诉它从特定捆绑。
如果您的问题更像我的问题,并且简单的 NSLocalizedString 还不够,那么以下是应该可以帮助您的确切代码:
由于您可能有多个标签,因此最好将路径存储为类属性,并且在 viewDidLoad 中设置,因此您将能够从该类内的任何方法/函数访问它。
First of all, I don't understand why you can't simply use
NSLocalizedString
when setting the label text, it does exactly what you want, loading the appropriate version of the text, according to the device's language.Anyway, I think you could find something useful here.
I actually did something similar, with six languages and only a single Nib but in my case I could have had the language changed inside the app, so I needed to be able to forcefully tell it to load me the localized version of a string from the specific bundle.
Here's the exact code that should help you in case your problem is more like mine and a simple NSLocalizedString is not enough:
Since you will probably have more than one label, it would be a good idea to have the path stored as a class property and set in viewDidLoad, so you will be able to access it from any method/function inside that class.