我的应用程序包含两个用于英语和阿拉伯语的XIB文件。我想在语言更改时更改XIB文件而无需重新启动应用程序。如何在不重新启动应用程序的情况下更改ios中的语言?
1
A
回答
0
我在我最近的项目中完成了同样的任务需要支持阿拉伯文&英文。我需要根据列表中选定的选项更改语言。我已经创建了两个的.xib一个阿拉伯文和一个用于英语,然后选择//用于再根据您可以使用您的厦门国际银行设置捆绑
+(void) setContentBundle{
SS AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
NSString *currentLanguage;
if([delegate.strLanguage length]> 0)
{
currentLanguage = delegate.strLanguage;
}else {
currentLanguage = @"en";
}
if ([currentLanguage isEqualToString:@"ar"]) { // If ARABIC.
languageBundle = nil;
NSString* path = [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"];
languageBundle = [NSBundle bundleWithPath:path];
}else if ([currentLanguage isEqualToString:@"en"]){ // If ENGLISH.
languageBundle = nil;
NSString* path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];
languageBundle = [NSBundle bundleWithPath:path];
}
}
// getting localiation key value
+(NSString *)getLocalizedStringForKey:(NSString *)key value:(NSString *)v table:(NSString *)t{
if([key isEqualToString:@"FollowUp.DepartmentKey"]){
NSLog(@"%@",key);
}
SSAppDelegate *delegate = (SSAppDelegate *)[UIApplication sharedApplication].delegate;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"KEY LIKE[c] %@",
key];
NSArray *filteredArray = [delegate.arrSystemMessages filteredArrayUsingPredicate:predicate];
NSLog(@"%@", filteredArray);
if(filteredArray!=nil && [filteredArray count]>=1){
NSMutableDictionary *dict=[filteredArray objectAtIndex:0];
if([[ContentBundleManager selectLanguage] isEqualToString:@"ar"]){
return [dict valueForKey:@"AR"];
}else{
return [dict valueForKey:@"EN"];
}
}else{
return [[ContentBundleManager getContentBundle] localizedStringForKey:key value:v table:t];
}
}
//for getting bundle
+(NSBundle *) getContentBundle{
SSAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
NSString *currentLanguage;
if([delegate.strLanguage length]> 0)
{
currentLanguage = delegate.strLanguage;
}else {
currentLanguage = @"en";
}
if ([currentLanguage isEqualToString:@"ar"]) { // If ARABIC.
languageBundle = nil;
NSString* path = [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"];
languageBundle = [NSBundle bundleWithPath:path];
}else if ([currentLanguage isEqualToString:@"en"]){ // If ENGLISH.
languageBundle = nil;
NSString* path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];
languageBundle = [NSBundle bundleWithPath:path];
}
return languageBundle;
}
/// and call .xib
SSBaseViewController *baseView= [SSLBaseViewController getBaseViewObjectWithBundle:nil];
/// and call string file
[baseView setHeaderTitle:[ContentBundleManager getLocalizedStringForKey:@"FollowUp.FollowUpKey" value:@"" table:nil]];
相关问题
- 1. 在应用程序中更改语言 - 如何重新启动?
- 2. 在不重新启动的情况下应用vimrc更改
- 3. 在不重新启动rails的情况下更改ruby模块应用程序
- 4. 如何在不重新启动的情况下卸载程序
- 5. 在UWP中更改语言不会更改系统功能语言 - 仅在应用程序重新启动时
- 6. 如何在不重新启动的情况下构建Revit应用程序
- 7. 如何在不重新启动的情况下调试PyQt应用程序?
- 8. iOS:如何以编程方式更改应用程序语言而无需重新启动应用程序?
- 9. 在不重新启动服务的情况下更改jobcron
- 10. 在不重新启动C#应用程序的情况下刷新GAC引用
- 11. 如何在更改语言环境时防止应用程序重新启动?
- 12. 如何在不重新启动设备的情况下重新启动应用程序系统?
- 13. 更改iOS应用程序语言,而无需重新启动设备
- 14. 在不重新启动应用程序的情况下动态更改python中的日志级别
- 15. 如何在iOS9中更改应用程序的语言而无需重新启动应用程序?
- 16. iOS - 在不更新应用程序的情况下更新用户流程
- 17. 在iOS中更改应用程序语言而无需重新启动应用程序
- 18. 如何在不重新启动grails应用程序的情况下更改.less文件?
- 19. 更改ios应用程序的语言
- 20. iOS - 通过编程更改应用程序特定的语言,无需重新启动应用程序
- 21. 如何在不重新启动的情况下关闭另一个应用程序的Win应用程序?
- 22. 在不重新启动的情况下调试已运行的应用程序
- 23. 如何在不重新安装的情况下更新winform应用程序
- 24. 如何在无需停止/重新启动程序的情况下使用IntelliJ应用css更改
- 25. 如何以编程方式更改应用程序语言无需重新启动我的应用程序?
- 26. 如何在不重新启动程序的情况下禁用AspectJ?
- 27. 如何在不重新启动Tomcat的情况下更改HTML/JS/CSS?
- 28. 在不重新启动lighty的情况下更新.po文件
- 29. 在不退出iPhone的情况下重新启动应用程序
- 30. 在不重新启动应用程序的情况下删除/清除sqlite dB
我认为你需要检测当前iPhone的输入语言
文件。 – jamil
可能的重复[如何以编程方式更改应用程序语言而无需重新启动我的应用程序?](http://stackoverflow.com/questions/15786501/how-to-change-app-language-programmatically-without-restarting-my-app) – rptwsthi