改变语言
如何更改 iPhone 应用程序的语言?
我的意思是,例如:在我的应用程序中,有一个标签,我想放一个荷兰语单词。 是什么 简单的方法。
从属性文件中读取
在项目中使用字符串变量创建一个静态类。
或者可能对属性文件进行任何更改。
请帮助我...谢谢并问候所有人
how to change the language in iPhone application ?.
i mean eg : in my application one label is there i want put a dutch word . what is the
easy way.
read from property file
make one static class in project with string variable.
or is possible any change in property file.
pls help me... thnx and regards all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此建立了大量的基础设施。 基本上,NSBundle API 具有本地化的概念,并且透明地将通过它们的任何内容重定向到适当的本地化版本(如果可用)。 如果您在捆绑包中看到过“.lproj”,那是用于本地化的。
好的,那么问题是如何设置呢? 使用 nib 很容易,您只需将 nib 的多个副本放入您的应用程序中,每个 lproj 中一个。 字符串有点棘手,你要做的是创建一个 Strings.localized 文件,然后每当你需要一个字符串时,你可以通过调用 NSLocalizedString(),它将在您的 Localized.strings 文件中查找字符串当前语言。
Xcode 有一些内置方法可以快速设置。 您可以选择任何资源并打开“获取信息”窗口,其中将有一个标题为“可本地化”的按钮。 单击该按钮后,将出现另一个按钮“添加本地化”,可以将特定的本地化添加到项目中。 此时,您的资源旁边将出现一个显示三角形,可让您在每个特定区域设置中编辑资源。
有许多不同的方法可以处理其中一些事情,具体取决于您的应用程序,并且Apple提供了一些工具来使这变得更容易。 这是一篇不错的博客文章关于如何本地化事物。
您应该记住的是,如果您正在查找本地化并根据它手动决定要使用哪些资源,您可能会做错。 大多数时候,您只是想识别需要本地化的位置,并通过为您处理该问题的 API 向系统请求资源(NSLocalizedString()、-[NSBundle pathForResource:ofType:] 等)。
There is a ton of built infrastructure for this. Basically the NSBundle APIs have the concept of localization, and transparently redirect anything that goes through them to an appropriately localized version if one is available. If you have ever seen a ".lproj" in your bundle, that is for localization.
Okay, so the question is how do you set that up? With nibs it is easy, you just put multiple copies of the nib into your app, one in each lproj. Strings are a little bit trickier, what you do is create a Strings.localizable file, then whenever you need a string you get it by calling NSLocalizedString(), which will lookup the string in the Localized.strings file of your current language.
Xcode has some built in ways to set this up quickly. You can select any resource and bring up the Get Info window there will be a button titled "Make Localizable." Once you click that there will be another button "Add Localizations," which lets add specific localizations to the project. At this point there will be a disclosure triangle next to your resource that lets you edit the resource in each specific locale.
There are a number of different ways to handle some of these things, depending on your App, and there tools Apple provides to make this easier. This is a decent blog post about how to localize things.
The thing you should remember is that if you are looking up the localization and manually deciding what resources to use based on it you are probably doing it wrong. Most of the time you simply want to identify the place that requires localization and ask the system for the resource through an API that handles that for you (NSLocalizedString(), -[NSBundle pathForResource:ofType:], etc).