How do I change my applications default language within my application? I am trying to change my applications language to Arabic, and I'm not sure how to accomplish this.
Asked
Active
Viewed 269 times
2
-
1You can find answer here, http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language – Hasintha Janka Apr 02 '12 at 06:04
1 Answers
4
There is a way:
First make a different folder named as ar.lproj
and put localizable.String
May following sample code help you. You can call this function in viewWillAppear
with the key for which you need to get value.
-(NSString*) languageSelectedStringForKey:(NSString*) key
{
NSString *path;
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
if([[userDefault valueForKey:@"language_Selected"] intValue] == 0)
path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];
else if([[userDefault valueForKey:@"language_Selected"] intValue] == 1)
path = [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"];
NSBundle* languageBundle = [NSBundle bundleWithPath:path];
NSString* str=[[languageBundle localizedStringForKey:key value:@"" table:nil] retain];
return str;
}
Hope you will understand the concept.

Lucifer
- 29,392
- 25
- 90
- 143

Neelam Verma
- 3,232
- 1
- 22
- 33