xcode国际化.strings

1、创建国际化.strings文件

创建国际化.strings文件

2、将国际化文件加入bundle中

国际化文件存放于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、开启和关闭模拟器的竖屏

控制模拟器的界面显示的横竖
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,262评论 4 61
  • 见www.jianshu.com/p/59279b018217 Application can be killed...
    heatbeats阅读 3,093评论 0 0
  • 每个八字都是一本书,一本由灵魂谱写的“书”。从“书”中我们可以看到欲望,各种丑恶,肮脏或高尚的东西。、这些“东西”...
    新派命理师阅读 401评论 0 0
  • 一、简介 冒泡排序法又称为交换排序,其比较方式由第一个元素开始,比较相邻元素大小,若大小顺序有误,则对调后再进行下...
    野狗子嗷嗷嗷阅读 382评论 0 1
  • https://www.axure.com/support/training/core/3-static-wire...
    张金富呵呵阅读 491评论 2 1