在运行时本地化 iPad 应用程序
我正在开发一个需要在运行时本地化的应用程序,我的意思是它将是一个立即更改语言的按钮,我搜索了有关本地化的信息,我发现的是如何根据 iPhone 本地化应用程序国际语言。
我已经本地化了我拥有的所有 nib 文件,并根据其语言重新设计了每个 nib 文件,但是当用户单击按钮时如何更改 nib 文件?
任何帮助将不胜感激。
I'm developing an app that require a localization at run time, i mean that it will be a button to change the language instantly, i've searched about localization and what i've found is how to localize the app depend on the iPhone international language.
I've localize all the nib files i have and redesign each nib file according to it's language, but how i can change the nib file when the user click on the button ?
any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
主要您可以使用某人创建的项目:iOS 应用程序中的高级本地化
或者还有另一种方法,您可以自己实现。您的项目中必须有所有本地化文件:
此代码适合您的需要。但这只是基础。因此,每个文本都必须使用
get:alter:
方法加载,以便以正确的语言加载。正如您在初始化时看到的,此类将使用系统语言,但在调用 setLanguage 方法后,它将使用您设置的语言。使用get:alter:
方法设置语言后,您应该通过为每个文本再次调用get:alter:
方法来重新加载视图控制器中的所有文本出现并将结果设置为所需的标签或文本字段或任何其他需要 i18n 的 NSString 类型参数。所以还有更多的工作要做,但这是一个非常好的基础。我认为这不会自动发生,你必须编码。Mainly you can use a project created by someone: Advance Localization in iOS apps
Or there is another method, to implement it by yourself.You must have all localization files in your project:
This code is good for what you need. But this is only the base. So each text must be loaded with the
get:alter:
method, so it will be loaded in the correct language. As you see at initialization this class will use the system language, but after you call thesetLanguage
method, then it will use the language you've setup. After you set a language with theget:alter:
method, you should reload all your text in your view controller, by calling theget:alter:
method again for each text that appears and set the result to the desired label or textfield or to any otherNSString
type parameter that needs i18n. So there is more work, but this is a very good base. I don't think it can happen automatically, you have to code.请参阅我对 的回答创建本地化的 iPhone 应用程序,但允许用户更改应用程序的语言。
基本上,您将本地化分为表和包,而不是使用内置本地化系统。您可以从每种语言的表中查找字符串,并从每种语言的包中查找 nib 文件。
See my answer to Creating a localized iPhone app but allowing the user to change language for the application.
Basically, you split up your localizations into tables and bundles rather than using the built-in localization system. You look your strings up from per-language tables and your nib files from per-langage bundles.