Reputation: 1408
How to integrate two languages (english or arabic) in one poject in iphone sdk? Please Help me with code or anything else which is helpful to me.
Upvotes: 5
Views: 1082
Reputation: 58
[[NSUserDefaults standardUserDefaults]setValue:@"ar" forKey:@"lang"];
[[NSUserDefaults standardUserDefaults]synchronize];
just do that thing there is an Localized Clases it will be very easy for you
Upvotes: 2
Reputation: 1408
i did like this.
lang = [[[NSUserDefaults standardUserDefaults]valueForKey:@"Selected_Lang"]intValue];
if(lang == 0 )
{
NSString *language = @"en";
LocalizationSetLanguage(language);
}
else
{
NSString *language = @"ar";
LocalizationSetLanguage(language);
}
Upvotes: 0
Reputation: 16864
You can also set the testing codition and then the validating flag.
Set the language
- (IBAction)btnTapped:(id)sender{
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
if([sender tag] == 1){
[[NSUserDefaults standardUserDefaults]setValue:@"en" forKey:@"lang"];
[[NSUserDefaults standardUserDefaults]synchronize];
delegate.imgV.image=[UIImage imageNamed:[NSString stringWithFormat:@"t1.png"]];
}else{
[[NSUserDefaults standardUserDefaults]setValue:@"ar" forKey:@"lang"];
[[NSUserDefaults standardUserDefaults]synchronize];
delegate.imgV.image=[UIImage imageNamed:[NSString stringWithFormat:@"at1.png"]];
}
[self presentModalViewController:delegate.nvCtr animated:YES];
}
Checking your conditions
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"lang"] isEqualToString:@"en"]) {
//Do your code here
}
else if([[[NSUserDefaults standardUserDefaults] valueForKey:@"lang"] isEqualToString:@"ar"]{
//Do your code here.
}
This code helping to solve your problem easily
@samuel.
Upvotes: 0
Reputation: 12780
You have to use localization for integrate two language in your app. for implementation you can refer this tutorial Localization
Upvotes: 1