1
votes

My iOS app support English language, I want to allow the user to make switch and change the language to Arabic if he want (a language from right to left) I made localization for strings in the app. Also I want to reflect all components in the UI.[put right components on left , and left on right , and make the alignment of titles from right to left] When I mad auto layout and if my device locale is English , components are reflect dynamically. But I want to force reflecting them when the user change the language inside the app it self and not the language of the device. What is the best way for doing this ? .. Thanks,

1
This is possible using common localization technique in iOS9, on older versions there wasn't a fully left-to-right supportAndrea

1 Answers

0
votes

You can do this using the AppleLanguages user default:

NSMutableArray* arr = [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] mutableCopy];
[arr removeObject:targetLang];
[arr insertObject:targetLang atIndex:0];
[[NSUserDefaults standardUserDefaults] setObject:arr forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];