iOS9-App with English and Arabic language

My app will ask user to choose language on launch time. If user choose english, layout, text are based on Left To Right (normal flow).


If user choose Arabic, app will load texts from Arabic.string (lproj bundle) BUT how my app inform to iOS UI kit to reflect Right To Left layouts. e.g. Right To left navigation changes, CollectionView flow layout in Right To Left.


Is there any common UIKit API to set languages?

OR

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"Ar", nil] forKey:@"AppleLanguages"]

will take care of Right To Left Layout positioning?


NOTE: My app will NOT depend on user's device locale. Business of my app tells that User should have option to select language hence we have to go off-track with traditional iOS language selection.

Replies

You're going to be swimming up stream if you attempt this. If you stomp on the AppleLanguages then various things won't behave as they normally would. Your app's user interface won't automatically flip you layout to be RTL, locale settings used for formatters won't be affected, and other things. You're going to be fighting a losing battle here so I'd strongly recommend you not go this route.


Can you talk a bit more about the business reasons that you feel you need to do this?

Thanks pdm. I know that its against the conventional way of handing language in iOS. Its more or like Web behavior.

Here is my app overview.


App is about country information and provide what's special about that country where user lives.


Example: India and Dubai. Where we have content available in backend system in Hindi and English for India and Arabic and English for Dubai.


Normal flow of app (In-App language selection):

Indian user opens app and selects India as country of residence and Hindi as language. Server will provide all content in Hindi. App will display numbers, date&time, currency etc. in Indian Region/Calendar (country of residence)

Dubai user opens app and selects Dubai as country of residence and Arabic as language. Server will provide all content in Arabic. App will display numbers, date&time,currency etc. in Dubai Region/Calendar (country of residence) with RTL writing direction.


If you see, app supports English, Hindi and Arabic overall. (lproj bundled but its based on case.) But no where we have used device locale,region format values.


Here business rules are followed as we have given user to choose their language.


Device Language:

Lets say app depend on device language.

Dubai user sets hindi in his iPhone (may be familiar with that). He opens the app and selects Dubai as country of residence. Language will be automatically selected as Hindi here. But at server system side all contents are either in Arabic or in English for Dubai. Thats kind of issue if we depend on device language.


Let's say we defined default language in system as Arabic for Dubai in above case, still number formatter, date&time, currency in Indian Region/Calendar (device region setting). Thats issue here. Content in Arabic but pricing, number, date&time in Indian format.


In both the solutions (in-app selection or device language), we have to deal with the scenarios where we have to force iOS framework to go away with device language.


Let me know your thoughts on this. Thanks a lot again.

Hi HShah and PDM,


I have a similar problem where we want to allow user to select an in app language which will over ride the language setting on device. For example, the device can be running in English but user from within the application should be able to select say Chinese or any other language. I know this is not a traditional way or preferred way of doing localization on iOS, but the business requires it. I know this would require some non-conventional changes. So is there a clean way of doing it which would involve least amount of hacks? 😕


Regards,

Bhavik

You can call this code after selecting language


[[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];



And try to reload root view controller after that