Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone App Localization - English problems?

I have an app that I am translating to a bunch of different languages. The problem is that the app will have a few different values in Australia than will in New Zealand, which are both English speaking countries.

I have created an en_AU and an en_NZ language file, but they're both using the standard English file. I deleted the English language file, but it continues to happen...

Any ideas on how I can get this to work?

Thank you,

--d

like image 698
dewberry Avatar asked Jul 22 '10 11:07

dewberry


People also ask

How do I get rid of localization on Iphone?

Here's how: Go to Settings > Privacy, then select Location Services. Select an app, then turn Precise Location on or off.

How do I change my localization on App Store?

Luckily if you have your app on iOS and Android, localization works similarly for Google Play as it does for App Store. To add a new locale in Google Play Console: On the left menu, click Store presence > Store listing. Under "Product Details," click Manage translations > Add your own translation text.


1 Answers

iPhone localisations (or is that localizations?) do not take any notice of the Region the user sets (ie, UK, Aus, NZ). There is only one "English" language translation available by default. However, you can hack around with things to force it to use a different translation setting - I've just done this for choosing between "English" (US) and "en_GB" (British english).

In your main.m file, alter it so it looks something like below (put in your own tests for NZ or AU)

int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// Set up the locale jiggery pokery
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
NSString *locale = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
if ([language isEqualToString:@"en"] && [locale isEqualToString:@"GB"]) {
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en_GB", @"en", nil] forKey:@"AppleLanguages"];
}

int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;

}

This pops the users language (eg "en") into the language NSString, and the users locale (eg, NZ, GB, AU) into the locale NSString. If they (in my case) match en and GB, then I set the users default language preference settings to be "en_GB", then "en".

Then, in your application delegates application:didFinishLaunchingWithOptions method you want to remove that NSUserDefaults setting you just set with the code

    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];

It's safe to remove at this point because all the bundle initialisation has been completed. Your app should now be using a Localization.strings file within the en_GB.lproj directory.

It's a bit of a horrible, hacky solution, but it works for me.

like image 190
rickerbh Avatar answered Nov 15 '22 14:11

rickerbh