iPhone - 强制本地化 Default.png

发布于 2024-09-18 10:15:44 字数 367 浏览 0 评论 0原文

我知道如何使用此代码强制本地化

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"fr", nil] 
forKey:@"AppleLanguages"];

,并且我知道如何本地化 Default.png(不同的捆绑包 English.lproj、French.lproj...)。现在假设手机语言是英语,但用户将应用程序语言设置为法语。 如何强制应用程序使用 French.lproj 中的 Default.png?

我尝试将上面的代码放在 main() 中,甚至在 UIApplicationMain() 之前,但它不起作用。

I know how to force localization with this code

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"fr", nil] 
forKey:@"AppleLanguages"];

And I know how to localize Default.png (different bundles English.lproj, French.lproj...). Now imagine the phone language is English, but the user set the application language to be French.
How can I force the app to use the Default.png in French.lproj?

I tried to put the code above in main() even before UIApplicationMain(), but it doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你爱我像她 2024-09-25 10:15:44

尽管听起来很疯狂,但我认为“苹果方式”做到这一点是在你的应用程序中根本没有语言设置。实际上,您根本不应该在应用程序中进行任何设置。您应该创建一个设置捆绑包,该捆绑包将显示在“设置”应用程序中。我知道很少有应用程序会这样做,因为并非所有用户都知道“设置应用程序”中有特定于应用程序的设置,但这是“正确”的方法。

但是,我认为这不会解决您的 Default.png 问题。要加载正确的 Default.png,您的应用程序应严格遵守系统语言设置,即。你根本不应该有任何语言设置。

As crazy as it may sound, i think the "Apple way" to do this is not have a language setting inside your App at all. Actually you shouldn't have any settings in your App at all. You should create a settings bundle that will show upp in the Settings app. I know that very few apps do this as not all users are aware that there are App-specific settings in the Settings App, but this is the "right" way around.

However, I do not think this will fix your Default.png issue. To load the correct Default.png, your app should strictly adhere to the system language setting ie. you should have no language settings at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文