Jag
Jag

Reputation: 987

Multi Language Support in iphone application

I want to develop an iphone application where u can change the language from the application itself rather than iphone settings.

How can it be possible?? Is there any tutorial available for it??

Waiting for the responses.

Regards, Jagruti

Upvotes: 1

Views: 646

Answers (1)

Srinivas
Srinivas

Reputation: 983

+(void)GetLangKey:(NSString *)Langkey
{
    NSString *tmpstr=[NSString stringWithFormat:@"%@",[[NSBundle mainBundle]pathForResource:@"LanguageResources" ofType:@"bundle"]]; 
    tmpstr =[tmpstr stringByAppendingString:@"/"];
    tmpstr=[tmpstr stringByAppendingString:Langkey];
    tmpstr =[tmpstr stringByAppendingString:@".lproj"];

    //  NSLog(@"%@",tmpstr);
    myLocalizedBundle=[NSBundle bundleWithPath:tmpstr];
}

+(UIImage*)GetLocalImage:(NSString *)ImgName
{
    NSString *filepath= [myLocalizedBundle pathForResource:ImgName ofType:@"png"]; 
    UIImage *returnImg=[UIImage imageWithContentsOfFile:filepath];
    return returnImg;
}

+(UIImage*)GetLocalImage:(NSString *)ImgName Type:(NSString *)imgType
{
    NSString *filepath= [myLocalizedBundle pathForResource:ImgName ofType:imgType]; 
    UIImage *returnImg=[UIImage imageWithContentsOfFile:filepath];
    return returnImg;   
}

+(NSString *)getLocalvalue:(NSString*)Key
{
    NSString *localValue=NSLocalizedStringFromTableInBundle(Key,@"Localized",myLocalizedBundle,@"");
    //NSLog(@"%@",localValue);
    return localValue;
}

when you changed Language change kay
[YourAppDelegate GetLangKey:(btn_Language.selected)?@"sp":@"en"];

Create Two Bundles As Strings Files Names Sp.lproj AND en.lproj Give Same Key For Both Strings Get Value Like Below [YourAppDelegate getLocalvalue:@"Settings"];

Upvotes: 2

Related Questions