ProTip: Force Use of Another Localisation in Development (Objective-C)

I’m currently working on a bilingual Welsh/English app and while I was really happy to hear that iOS 8 will treat Welsh as a first class language, currently it does not. Making a Welsh localisation work is a pain.

I came across this handy fix to force the current build to load a Welsh localization. Assuming that you have Welsh set up as a localisation in XCode, you can force the device to think that Welsh is the first choice language and read in those strings instead of the default (in my case, English). This means when presenting to clients, I can ask the app to load in Welsh or English by changing a line of code and then submit the two apps separately to the app store.

In main.m before return [UIApplicationMain ...] just stick in these lines:

NSArray *langOrder = [NSArray arrayWithObjects:@"cy", nil];
[[NSUserDefaults standardUserDefaults] setObject:langOrder forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];

Job done. Replase cy with en or any other language you have set up and you can force loading a particular language in development.