0

If i would need change only text string it will simple, but How can I change images or xib files (which are for each localisation)?

code which set localisation:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"Ukrainian", @"English", nil] forKey:@"AppleLanguages"];

or

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects: @"English", @"Ukrainian", nil] forKey:@"AppleLanguages"];

(if I have done this code, and app was closed so next time when app start it use all resources which set for selected language)

How can I do the same but without restarting app?

I found many examples, but these show how work with text, but how work with another resources, and how can I their update (for current select language)?

examples: Change iOS app's language on the fly

language change only after restart on iphone

Community
  • 1
  • 1
Vit
  • 936
  • 1
  • 10
  • 20
  • 2
    This question has been asked 10+ times on SO alone, clearly no research at all. One of them: http://stackoverflow.com/questions/4238979/how-programatically-restart-iphone-app – Rob Apr 03 '13 at 11:50
  • 1
    There are ways to change the language dynamically... – dsgriffin Apr 03 '13 at 11:50

3 Answers3

1

You can't do that (without jailbreaking). You should code your app in a way, that you can start over when some significant information changes, without restarting the app. For instance you could pop all the view controllers and deallocate them and then let the user reload them using the correct language.

Note however, that normally you shouldn't do anything like that. Localization is solved in a quite elegant way on iOS. You just localize the .strings (and optionally .nib and image files) and the system takes care for the rest for you. When the user changes the language in the Settings app, you app will be terminated by the system. The next time the user starts the app, it will load the correct language.

DrummerB
  • 39,814
  • 12
  • 105
  • 142
0

Why restart the application?I think it is not possible.But you can do whatever to change in the applicationDidBecomeActive or applicationWillEnterForeground Method

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

It's not possible,

Though there is one trick

1> From your application Open safari Browser with custom URL (e.g. com.yourcompany.yourApp)

2> register that Custom URL with your app(from plist file you can do that), which will open your application from safari when that custom url open in safari.

3> turn off your "Application should run in background" from your .plist file. (you can achieve this by adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES.)

Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88