Changing language on the fly, in running iOS, programmatically

gabrielstuff picture gabrielstuff · Feb 24, 2011 · Viewed 41k times · Source

I've been stackling and googling for hours. And I'm kind of desperate now. I would like to change the language of my application inside the app not only with the default language.

From what I've tried I stuck like everybody with the reboot step. Meaning, apples forces you to restart the app manually. Meaning you have to quit the app and then starting it up again.

Well, after googling, I was trying to setup an alarm and then forcing later the app to exit with

exit(0);

My bad, apple seems not to like this and prevent developer from using it... I guess I'm not pointing in the right direction.

Finally, despite all the problem, I could meet I would like to discuss about that.

Any hints?


EDIT, infos from APPLE

In general, you should not change the iOS system language (via use of the AppleLanguages pref key) from within your application. This goes against the basic iOS user model for switching languages in the Settings app, and also uses a preference key that is not documented, meaning that at some point in the future, the key name could change, which would break your application.

If you want to switch languages in your application, you can do so via manually loading resource files in your bundle. You can use NSBundle:pathForResource:ofType:inDirectory:forLocalization: for this purpose, but keep in mind that your application would be responsible for all loading of localized data.

Regarding the exit(0) question, Apple DTS cannot comment on the app approval process. You should contact [email protected] to get an answer for this question.

Well, I have to choose so far.

Answer

Swissdude picture Swissdude · Sep 3, 2011

This is a fairly old question, but I was just struggling with the same problem and found this solution:

http://aggressive-mediocrity.blogspot.com/2010/03/custom-localization-system-for-your.html

Which does exactly what you need (and might be helpful for others who with the same problem :)