1

enter image description here

App support's English and French Localisation, But in Specific case when user select any other Locale except these two (English&French) i need to use french as default language,but its not working.can anybody suggest me how to keep French(Fr) as default when any other language is selected.Thanks

I changed plist:- Localization_native_development_region to fr(french).

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
Garry
  • 41
  • 7

2 Answers2

2
  1. Change your Localization Native Development region in your Info.plist to French (I see you've already done that :))
  2. Open your .xcodeproj/project.pbxproj file and change the developmentRegion value to French
  3. Re-open your project, select your project file and then add a French localisation
  4. Remove the English localisation

You should be good to go now.

wakachamo
  • 1,723
  • 1
  • 12
  • 18
  • Thanks for response, I need to keep Franch as default when any other language is selected but if user select english then there should be english localisation.i tried your suggestions but it doesn't keep franch as default when any other language is selected. I have Base language is Franch in localisation – Garry Mar 17 '16 at 05:33
  • But op has english + french both languages support. – Hemang Mar 17 '16 at 05:53
0

Whatever the language user have selected inside your app. You have to force setting that language in your app. manual language selection in an iOS-App (iPhone and iPad) you should make that language selection in your AppDelegate's - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {...} method. So whatever the language is in user's device, it won't effect your app.

In your case:

NSString *currentLang = [[NSUserDefaults standardUserDefaults] valueForKey:@"currentLang"];
if([currentLang length]) {
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:currentLang, nil] forKey:@"AppleLanguages"];
    [[NSUserDefaults standardUserDefaults] synchronize];
} else {
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"fr", nil] forKey:@"AppleLanguages"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
Community
  • 1
  • 1
Hemang
  • 26,840
  • 19
  • 119
  • 186
  • Please never do this. This is not a supported configuration and much of your UI will still appear in the system language. – wakachamo Mar 16 '16 at 18:02
  • @wakachamo, this is just an answer to the user's required question. He needs to have the same function for his app. – Hemang Mar 16 '16 at 18:06
  • This can be accomplished without resorting to runtime hacks, as described in my answer. – wakachamo Mar 16 '16 at 19:22
  • @hemang. I used - NSString *language = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[[NSLocale currentLocale] localeIdentifier]];; to find current device language and did your suggested change further it works but i have to open and kill app first time. – Garry Mar 17 '16 at 05:36