App is terminated when user changes language

Dear Experts,

NSLocale has a notification NSCurrentLocaleDidChangeNotification and a property autoupdatingCurrentLocale ("A locale which tracks the user’s current preferences"). These suggest that an app should be able to detect when the user changes their language preference while running, or when it is resumed from the background.

In practice, when I change language in the Settings app (either globally or just for my app), the app is terminated by iOS and restarts with new locale.

Is this the expected behaviour? I am wondering if there is something I need to do to advertise that the app can adopt language changes without restarting, or something.

Maybe only date-time formats, etc., trigger the notification but language changes don't?

Accepted Reply

Maybe only date-time formats, etc., trigger the notification but language changes don't?

Exactly. Formatters and other objects that can refresh their data directly using Locale.current or Locale.autoupdatingCurrent are expected to be able to do so when they receive currentLocaleDidChangeNotification. However, when you change the Device Language or the App Language, not every app is currently able to dynamically update their UI Layout, which is why the app is terminated and relaunched for such events.

  • Also note that macOS apps do not necessarily get restarted on locale change.

Add a Comment

Replies

Maybe only date-time formats, etc., trigger the notification but language changes don't?

Exactly. Formatters and other objects that can refresh their data directly using Locale.current or Locale.autoupdatingCurrent are expected to be able to do so when they receive currentLocaleDidChangeNotification. However, when you change the Device Language or the App Language, not every app is currently able to dynamically update their UI Layout, which is why the app is terminated and relaunched for such events.

  • Also note that macOS apps do not necessarily get restarted on locale change.

Add a Comment

Thanks. Is that documented somewhere?