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 应用程序设置默认语言
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
