Skip to content

Conversation

@wolfcon
Copy link
Collaborator

@wolfcon wolfcon commented Jul 7, 2021

New Features 新功能

Dynamic i18n Switching 动态切换多语言模块

Now MJRefresh components will be rerendered automatically with MJRefreshConfig.default.language setting.
如果设置了MJRefreshConfig.default.language, MJRefresh 模块 将会自动同步刷新.

Example 例子

Go i18n folder and see lots of cases. Simulator example is behind i18n tab in right-top corner.
i18n 目录下可以找到很多例子, 模拟器功能在右上角的 i18n (原示例2) 可以查看相应的部分功能.

Setting language 设置语言

MJRefreshConfig.default.language = "zh-hans"

Setting i18n file name 设置 i18n 的多语言文件名

MJRefreshConfig.default.i18nFilename = "i18n File Name(not include type<.strings>)"

Setting i18n language bundle 设置 i18n 的多语言 Bundle

MJRefreshConfig.default.i18nBundle = "i18n Bundle"

Adopting the feature in your DIY component 在自定义控件引入本次新增功能

Just override i18nDidChange function and reset texts.
重写 i18nDidChange 方法並且重设多语言内容.

// must use this localization methods
Bundle.mj_localizedString(forKey: "")
// or
Bundle.mj_localizedString(forKey: "", value:"")

override func i18nDidChange() {
    // Reset texts function
    setupTexts()
    // Make sure to call super after resetting texts. It will call placeSubViews for applying new layout.
    super.i18nDidChange()
}

…ically with `MJRefreshConfig.default.language` setting.
@wolfcon wolfcon added the enhancement 功能优化/增强 label Jul 7, 2021
@wolfcon wolfcon merged commit 7edc769 into master Jul 13, 2021
@wolfcon wolfcon deleted the feature/dynamic-i18n branch July 13, 2021 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 功能优化/增强

Projects

None yet

Development

Successfully merging this pull request may close these issues.

多语言无法动态切换 国际化 languageCode无法动态更改

3 participants