+(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"];
Создание двух пакетов в виде строк Имена файлов Sp.lproj AND en.lproj
Дать одинаковый ключ для обеих строк
Получить значение, как показано ниже
[YourAppDelegate getLocalvalue: @ "Настройки"];