2

I want to change the language and the region format within in the application. I can do something this to change the language.

int main(int argc, char * argv[])
{
  @autoreleasepool {

    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"zh_CN", nil] forKey:@"AppleLanguages"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  }
}

Then quit the app using exit(0); once user changed the language.

Change Language in the app programmatically

But how can I change the region format to match the selected language? Is this doable?

Community
  • 1
  • 1
smartsanja
  • 4,413
  • 9
  • 58
  • 106

1 Answers1

0

Change Language in the app programmatically. Or check it manually.

NSBundle* languageBundle = [NSBundle bundleWithPath:path];
NSString* lan = [languageBundle localizedStringForKey:key value:@"" table:nil];
    
NSLog(@"%@: %@ %@",lan, 
    [NSLocale canonicalLanguageIdentifierFromString:lan], 
    [ [[NSLocale alloc] initWithLocaleIdentifier:lan]
        displayNameForKey:NSLocaleIdentifier value:lan]
);
marc-medley
  • 8,931
  • 5
  • 60
  • 66
Hardip Kalola
  • 196
  • 1
  • 4