Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

适配多语言 #1462

Closed
lxy8383 opened this issue Jan 18, 2021 · 8 comments
Closed

适配多语言 #1462

lxy8383 opened this issue Jan 18, 2021 · 8 comments

Comments

@lxy8383
Copy link

lxy8383 commented Jan 18, 2021

为了适配多语言 期望把这块修改一下

  • (void)setPreferredLanguage:(NSString *)preferredLanguage {
    _preferredLanguage = preferredLanguage;

    if (!preferredLanguage || !preferredLanguage.length) {
    preferredLanguage = [NSLocale preferredLanguages].firstObject;
    }
    if ([preferredLanguage rangeOfString:@"zh-Hans"].location != NSNotFound) {
    preferredLanguage = @"zh-Hans";
    } else if ([preferredLanguage rangeOfString:@"zh-Hant"].location != NSNotFound) {
    preferredLanguage = @"zh-Hant";
    } else if ([preferredLanguage rangeOfString:@"vi"].location != NSNotFound) {
    preferredLanguage = @"vi";
    } else {
    preferredLanguage = @"en";
    }
    _languageBundle = [NSBundle bundleWithPath:[[NSBundle tz_imagePickerBundle] pathForResource:preferredLanguage ofType:@"lproj"]];
    }

@banchichen
Copy link
Owner

banchichen commented Sep 21, 2021

我看下

@banchichen
Copy link
Owner

3.6.6已修复...

@sauchye
Copy link

sauchye commented Sep 29, 2021

IMG_0552
@banchichen 你好,弱弱的咨询一下下,我的设备系统是中文简体,App切换到阿拉伯语言,我怎么去更改这里列表的显示呢。
Controller的控制器TZAlbumModel模型获取name,我查到name的赋值代码

    TZAlbumModel *model = [[TZAlbumModel alloc] init];
    [model setResult:result needFetchAssets:needFetchAssets];
    model.name = collection.localizedTitle;

我分别在初始化前尝试,但是没有效果。另外我不是最新的类库= =,不是pod,之前更改了一些些,非常感谢!

                NSString *languageKey = @"zh-Hant";
                if (isArabicLanguage) {
                    languageKey = @"ar";
                } 
                [TZImagePickerConfig sharedInstance].preferredLanguage = languageKey;
                self.tzimagePickerVC.preferredLanguage = languageKey;

@banchichen
Copy link
Owner

@sauchye 相册的名字,参考下这个哈:
Q:系统语言是中文/英文,界面上却有部分相册名字、返回按钮显示成了英文/中文?
A:请参考 #443#929

@sauchye
Copy link

sauchye commented Sep 30, 2021

感谢感谢!相册的部分title是取的系统语言,我切换微信英文,相册依旧是系统中文。那RTL翻转只能自己去修改一些镜像的问题吗?如一些些icon,选中icon,预览视频都被翻转

@banchichen
Copy link
Owner

关于RTL,TZ做的事情很少,更多是系统做的,可以搜索下tz_isRightToLeftLayout,这是TZ关于RTL的判断和几处适配...

@sauchye
Copy link

sauchye commented Sep 30, 2021

感谢作者,我fork了一份,主要处理RTL视频翻转问题,以及back按钮需要翻转,https://github.com/sauchye/TZImagePickerController
这里集成了https://github.com/bytedance/AWERTL 类库,主要适配RTL
添加enableRTL全局设置RTL

#pragma mark - RTL
- (void)settingEnableRTL:(BOOL)enableRTL {
    /// RTL
    [TZImagePickerConfig sharedInstance].enableRTL = enableRTL;
    [AWERTLManager sharedInstance].enableRTL       = enableRTL;
}

// image 翻转
+ (UIImage *)tz_flipImage:(UIImage *)image;///<  flip picture eg:RTL

@sauchye
Copy link

sauchye commented Oct 9, 2021

@banchichen 谭老师下午好,在适配RTL出现一些疑问,最近将iOS设备切换到阿拉伯语言,点击相册列表图片进入图片预览界面

        TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init];
        photoPreviewVc.currentIndex = index;
        photoPreviewVc.models = _models;
        [self pushPhotoPrevireViewController:photoPreviewVc];
        NSLog(@"currentIndex %ld", index);

仔细查看了一下下,在RTL单独赋值了currentIndex ,这里直接取 _currentIndex即可
我这里集成了 https://github.com/bytedance/AWERTL 类库,主要适配RTL

- (NSInteger)currentIndex {
    return [TZCommonTools tz_isRightToLeftLayout] ? self.models.count - _currentIndex - 1 : _currentIndex;
}

https://github.com/sauchye/TZImagePickerController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants