views:

135

answers:

1

Hi, i want to change the locale programmatically in my iphone app (basically because not all languages are supported by iphone itself, it should be possible for the user to switch language only for my application). I have seen on a different question http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language that on OSX apps? it should work with [[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"de", nil] forKey:@"AppleLanguages"]; - but for me it doesn't... [NSLocale currentLocale] still returns the system wide locale and the 'main bundle' gives me files from the system wide locale..

so.. is there a way to set a custom locale for my application? or - which would be sufficient for me - create a new NSBundle instance with a different locale?

A: 

ok, stupid me.. as the question linked already answered.. that code requires a restart.. ie. when the user selects another language call [[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"de", nil] forKey:@"AppleLanguages"]; - the next time the application is launched the [NSBundle mainBundle] will return the correct resources for the given locale.. (although [NSLocale currentLocale] will still return the iphone-wide locale.. but i think this doesn't matter to me anyway...)

herbert