4

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?

Marco
  • 6,692
  • 2
  • 27
  • 38
erik
  • 4,946
  • 13
  • 70
  • 120
  • one semantic technicality: you are referring to a _change notification_ via the `NSNotificationCenter`, not a _push notification_ (which can be either local or remote, but is a different mechanism than the internal Objective-C notification system), you want to "post a notification" to the notification center. – bshirley Jun 26 '13 at 15:56
  • By notification, do you mean NSCurrentLocaleDidChangeNotification? – Marco Jun 26 '13 at 16:08
  • yes i want to POST NSCurrentLocaleDidChangeNotification – erik Jun 26 '13 at 16:45

2 Answers2

3

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];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
3

To programatically post the notification:

[[NSNotificationCenter defaultCenter] postNotificationName:NSCurrentLocaleDidChangeNotification object:self userInfo:nil];
Marco
  • 6,692
  • 2
  • 27
  • 38
  • question this posts region change or language change.. what i want to do is actually force a language change notification even if the language did not change – erik Jun 26 '13 at 16:58
  • doesn't seem to work.. when i change my language and come back to the app my localization is firing with the right dialect.. but if i just change the region from say united states to peurto rico.. and come back to the app it doesn't change my localized strings – erik Jun 26 '13 at 17:12