0

I want to Refer : Change iOS app's language on the fly first, in which a way to change Language is Given, i used it, it is working, but it requires Two ReLaunch of Application to take changes over Application. I want to do something in which, just on Button click my language should change

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de", nil] 
                                          forKey:@"AppleLanguages"];
Community
  • 1
  • 1
Mrug
  • 4,963
  • 2
  • 31
  • 53

1 Answers1

0

Use this -> [[NSUserDefaults standardUserDefaults] synchronize];

Edited Post

Put this macro in the Prefix.pch:

#define currentLanguageBundle [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[[NSLocale preferredLanguages] objectAtIndex:0] ofType:@"lproj"]]

and where ever you need a localized string use:

NSLocalizedStringFromTableInBundle(@"GalleryTitleKey", nil, currentLanguageBundle, @"")

For Setting use this as you are already using:-

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de", nil] 
                                          forKey:@"AppleLanguages"];
Vizllx
  • 9,135
  • 1
  • 41
  • 79
  • I am Doing this Also. but even though the Reflection is Observed after two Launches – Mrug Dec 02 '13 at 12:22