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

查看:127
本文介绍了首次运行时为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天全站免登陆