0

I am implementing multiple languages for my iOS 10+ app by following this tutorial: https://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014

The following Objective-C code helps to switch different languages:

NSArray* languages = [NSArray arrayWithObjects:@"ar", @"en", nil]; 
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];

And it says that the App needs to reload itself to take the changes into account. However, i could not find a clear reference how to do it. But commercial apps do reload themselves after language changes.

Do you know what is the direct and cleanest approach to perform an automatic reload of the app in such scenario? Thanks

stephane
  • 172
  • 14

1 Answers1

0

If you want to change AppleLanguages then you must restart the app so new language is applied , but if you want to change it without restart you have to change the current bundle of the app from main to languageCode.lproj so NSLocalizedString can read from it , find more info here Localization

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • Thank you . I understand that changing the bundle would allow runtime the language change. For restarting programatically the app, would you have a pointer? The idea would be that the user choose a new language the app reboot itself... – stephane Feb 20 '18 at 21:07
  • Actually you can't re launch the app again , after user agrees for language change popup ["App needs to be restarted to apply the new language"] set AppleLanguages to the needed language and then do exit(0) dispatched after 2 seconds user clicks agree – Shehata Gamal Feb 20 '18 at 21:10