首次运行时为 iPhone 应用程序设置默认语言 [英] Setting default language for iPhone app on first run

查看:29
本文介绍了首次运行时为 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 应用程序设置默认语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆