0

I'm new in iPhone app, I want to make my app bilingual "Supports both English and Arabic" by pressing a key to convert the language

could anyone tell me how to do this programmatically?

Note: I want to change the language of the app separately from the device language.

Thanks in advance.

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
Eman87
  • 2,735
  • 7
  • 36
  • 53
  • http://stackoverflow.com/questions/5748600/making-multi-language-ios-app Same question here. – juniperi Jun 19 '13 at 10:44
  • to change the language of the app, we must change the language of the iphone itself and I'm not want this, I want to change the language of the app itself separately from the device language. – Eman87 Jun 19 '13 at 12:29

1 Answers1

0

You can switch between languages on the fly by using:

NSString* path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];//use the language code here
NSBundle* languageBundle = [NSBundle bundleWithPath:path];

This will give you the bundle for particular language. Then you can get the particular translation for a key using:

[languageBundle localizedStringForKey:Key value:@"" table:nil];
Amit
  • 1,043
  • 1
  • 10
  • 32
  • to change the language of the app, we must change the language of the iphone itself and I'm not want this, I want to change the language of the app itself separately from the device language. – Eman87 Jun 19 '13 at 12:33
  • by this way you can change the language irrespective of device's language. For example if you give "de" instead of "en" it will set your app's language to italian and so on. – Amit Jun 19 '13 at 12:59
  • thanks, but now could you show me how to use this code exactly? because I'm new in iPhone. and how to use this '[languageBundle localizedStringForKey:Key value:@"" table:nil];' and what is the value ?? – Eman87 Jun 19 '13 at 13:18
  • The way you use localization normally, you need to pass a constant key to get exact localization value. Ex: '[languageBundle localizedStringForKey:@"Close" value:@"" table:nil]; will give you translation of key "Close" for all languages(keep value as @"" only). I think you should go through this tutorial prior implementing this - http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial – Amit Jun 20 '13 at 05:48