Skip to content

Releases: fwh1990/i18n-chain

v2.0.1

29 Dec 08:07
Compare
Choose a tag to compare

translate()翻译时,如果传入非字符串类型的key,将直接返回key。

v2.0.0

03 Nov 11:23
Compare
Choose a tag to compare

Breakings

  • 数据不再接入一级链条,需要从chain上获取(这种直接使用的场景也较少)
- const value = i18n.button.submit;
+ const value = i18n.chain.button.submit;
  • 删除下划线_,内置方法调整回一级链条
- i18n._.locale('zh');
+ i18n.locale('zh');
  • 删除useI18n,改成从实例获取chain
function App: FC = () => {
- useI18n(i18n);
+ const chain = i18n.use();

  return <div>{chain.button.submit}</div>; 
}
  • 删除高阶组件 I18nProvider,改成从实例获取hoc
class App extends Component {
  render() {
+   const { chain } = this.props; 

-   return <div>{i18n.button.submit}</div>;
+   return <div>{chain.button.submit}</div>;
  }
}

-export default I18nProvider(i18n)(App);
+export default i18n.hoc(App);

Features

  • 新增方法translate,与t一致,都是用于翻译字符串模板
  • 新增字符串模板生成工具
// 跟直接写字符串一样,但是这边是有提示的
const key = i18n.literal.button.submit; // key === 'button.submit'

// 可以使用translate方法获得真实的数据
const value = i18n.translate(key);  // value === 'Submit'

v0.4.2

04 Jan 08:37
Compare
Choose a tag to compare

Support low version browsers

v0.3.0

03 Jan 14:03
Compare
Choose a tag to compare

Remove .chain property

Before

i18n.chain.common.button.success

After

i18n.common.button.success

v0.2.0

03 Jan 09:33
Compare
Choose a tag to compare

Design cache to improve performance

v0.1.1

03 Jan 03:00
Compare
Choose a tag to compare

v0.1.0

02 Jan 14:45
Compare
Choose a tag to compare

Release stable version

v0.0.16

02 Jan 09:12
Compare
Choose a tag to compare