问题
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.
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?
回答1:
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.
Example - going from Spain to Mexico should change the locale from es_ES
to es_MX
.
Edit:
To post the notification you can do:
[[NSNotificationCenter defaultCenter] postNotificationName:NSCurrentLocaleDidChangeNotification object:nil];
回答2:
To programatically post the notification:
[[NSNotificationCenter defaultCenter] postNotificationName:NSCurrentLocaleDidChangeNotification object:self userInfo:nil];
来源:https://stackoverflow.com/questions/17324589/forcing-a-language-change-notification-ios