Setting default language for iPhone app on first run(首次运行时为 iPhone 应用程序设置默认语言)
问题描述
我正在开发一个应支持两种语言的应用程序:英语和法语.但是,由于尚未完成英文翻译,我们只想将其部署为法文,稍后再添加英文翻译.
I'm developing an application that should support two languages: English and French. However because English translation is not done yet we want to deploy it in French only and later on add English translation later on.
问题是我不想从我的代码中去除英语,因为某些部分已经完成,该语言有不同的 NIB 等等.相反,我只想在我的代码中暂时禁用英语应用程序.
The problem is that I don't want to strip English language out of my code since some parts are already done, there are different NIBs for that language etc. Instead I'd just want english language to be temporary disabled in my app.
我所做的是我把这段代码作为第一条指令
What I did is I put this code as the first instruction of
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSArray arrayWithObjects:@"fr", nil] forKey:@"AppleLanguages"];
[defaults synchronize];
除了一件事,它工作正常.安装后第一次启动应用程序时,它仍然是英文的.这可能是因为尚未为其设置 AppleLanguages
首选项.在我退出应用程序并重新启动后,它以法语正确显示.
It works fine except for one thing. When you launch the application for the first time after installation it's still in English. That's probably because AppleLanguages
preference was not yet set for it. After I quit the application and start it again it's being displayed correctly in French.
有谁知道在第一次运行时也应用了法语的修复方法?
Does anyone knows a fix so that French language was applied also on the first run?
推荐答案
听起来很乱.为什么不直接从目标中取消选中未完成的英语资源,这样它们就不会被部署?另外,您是否查看过 Info.plist 中的 CFBundleDevelopmentRegion 设置?
Sounds messy. Why not just uncheck the unfinished English resources from the target, so they won't get deployed? Also, have you looked into the CFBundleDevelopmentRegion setting in Info.plist?
这篇关于首次运行时为 iPhone 应用程序设置默认语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:首次运行时为 iPhone 应用程序设置默认语言


基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01