iOS 上的等效 ResourceString 文件
这就是整个故事。 我为很多平台编写了大量代码。 我真的很喜欢在 Java 和 .NET 中发现的概念,即资源文件可以包含您将在应用程序中使用的所有字符串。希望你们中的一些人知道这一点。它基本上是一个以 key=>value 的方式排序的 XML 文件。 我一直在寻找 iOS 中的同等产品,但我不清楚。有 infoPlist.strings,但这似乎是错误的路径。我可能错了。
所以我们想要的是,我们有一大堆在多个地方重复的字符串(警报框、方向文本等)。我们需要将这种体验变成一种改变。有多种方法可以做到这一点,我只是不知道哪一种最好。
我的口才不是很好,所以如果有人有疑问或需要澄清,请告诉我。
So here is the whole story.
I have done alot of code for a lot of platforms.
I really like the concept that I have found in Java and .NET with a resource file that can contain all the strings you will use in your app. Hopefully some of you know about it. It's basically an XML file sorted in a key=>value kind of way.
I have been looking for an equivalent in iOS but I'm unclear. There is infoPlist.strings, but that seems like the wrong path. I may be wrong.
So what we want is, we have a whole bunch of strings that get repeated in multiple places (alert boxes, direction text, etc.). We need that to be a change once kind of experience. There are multiple ways of doing this, I just don't know which one is the best.
I'm not really eloquent, so if anyone has questions or needs clarification, let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果本地化不是您想要做的,那么您可以将它们放入 plist 文件的字典中。让您的应用程序在应用程序启动时读取 plist 文件,并将其存储在全局变量或某个可以在整个应用程序中轻松引用的单例中。
If localization is not what you are trying to do, then you could just put them in a dictionary in a plist file. Have your app read the plist file at app startup and store in a global variable or some singleton that can be easily referenced throughout your app.
这是由定位系统处理的。看看
NSLocalizedString()
和 本地化字符串资源。它应该完全符合您的要求。This is handled by the localization system. Look at
NSLocalizedString()
and Localizing String Resources. It should do exactly what you are looking for.