Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change application language setting in iOS not the whole device

I want to have an option in my application to change my application language (just application language not the whole system), would you please give me some hints?

Thanks in advance,

I know about localisation!

like image 551
Elnaz Avatar asked Jul 20 '12 11:07

Elnaz


2 Answers

You can do this by using custom build flags that you set up from Xcode. This way you can run an application under a localisation rather than changing all the settings for the device.

I wrote a blog post about it at http://abizern.org/2012/03/18/simple-localisation-testing/

And there is an example project on Github that you can use to see it in action: https://github.com/Abizern/SimpleLocalisationTesting

like image 79
Abizern Avatar answered Sep 27 '22 23:09

Abizern


I've made custom localization made by .plist filled with array of dictionaries. Like this:

kYes
  en = @"Yes"
  ru = @"Да"
kNo
  en = @"No"
  ru = @"Нет"

In my project I made a singleton class for reading this strings. In options user selects needed language (at first start app select language from current system state or sets default one). Selected language must be saved in file or in settings to use on the next start. In singleton I have +getStringWithKey:. So I pass there @"kYes" and get string for current localization for app only. Also, you will need to add standard localization files to project anyway, even empty, because if you don't, all languages you support will not be shown in iTunes.

like image 30
Pavel Oganesyan Avatar answered Sep 27 '22 22:09

Pavel Oganesyan