强制更改语言通知iOS [英] Forcing a language change notification iOS

查看:91
本文介绍了强制更改语言通知iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序已本地化,我们关注方言. (即,西班牙语和peurto rico中西班牙语的区别)我注意到,仅更改区域不会将通知推送到将触发本地化的应用程序.仅更改语言会触发此通知.

my app is being localized and we are concerned with dialects. (ie. difference between spanish and spanish in peurto rico) I notice that just changing the region doesn't push a notification to the app that will trigger the localization.. only changing the language triggers this notification.

在我的应用程序委托中,我想检查一下我的applicationDidBecomeActive方法中该区域是否已更改,如果有更改,我想推送通知:如果语言已更改,iOS将会推送该通知.可能吗?

In my app delegate i would like to check to see if the region has changed in my applicationDidBecomeActive method and if it has, i'd like to push the notification that iOS would have pushed if the language had changed.. is that possible?

推荐答案

每当您的应用返回到前台(不是在其变为活动状态时),请获取当前语言环境.将最新的语言环境与以前的语言环境进行比较.如果新的和旧的语言环境对您来说足够不同,请发布通知.

Each time your app returns to the foreground (not when it becomes active), get the current locale. Compare the latest locale to the previous locale. If the new and previous locale are different enough for you, post the notification.

示例-从西班牙到墨西哥,应将语言环境从es_ES更改为es_MX.

Example - going from Spain to Mexico should change the locale from es_ES to es_MX.

修改:

要发布通知,您可以执行以下操作:

To post the notification you can do:

[[NSNotificationCenter defaultCenter] postNotificationName:NSCurrentLocaleDidChangeNotification object:nil];

这篇关于强制更改语言通知iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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