1、创建国际化.strings文件
2、将国际化文件加入bundle中
3、国际化文件的使用
//1、获取当前项目的资源bundle
+ (NSBundle *)frameworkBundle {
static NSBundle* frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
NSString* mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString* frameworkBundlePath = [mainBundlePath stringByAppendingPathComponent:@"项目名Resource.bundle"];
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
});
return frameworkBundle;
}
//2、获取当前项目资源bundle中的一个.strings文件的内容
NSString *path = [[DPLocalizationManager frameworkBundle] pathForResource:tableName ofType:@"strings" inDirectory:nil forLocalization:@"当前语言"];
NSDictionary *tableContent = path ? [NSDictionary dictionaryWithContentsOfFile:path] : nil;
//3、读取.strings文件中的对应的key值
NSString *result = self.tables[@"XGSDKLocalizable"][key];
4、开启和关闭模拟器的竖屏