1.0.5 • Published 7 years ago

cs-i18n v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

TOC

cs-i18n

react国际化组件

1. 国际化初始化

import Intern from 'CsI18n';
const zh = { "i18nDemo-demo-panelcontent": "面板内容" };
//初始化 
const intern = new Intern('zh', zh);

2. 语言切换

intern.changeLang('zh', zh).then(() => {
    this.setState();
    // do something you want to
});

3. 内容显示

<div>{i18n.message('i18nDemo-demo-panelcontent')}</div>

4. API

方法参数说明返回值事例
i18n.percent(number)number:需要格式化的数字格式化后的值i18n.percent(30) -> 3,000%
i18n.currency(number)number:格式化钱币格式化后的值i18n.currency(300) -> ¥300.00(中)
i18n.decimal(number)number:数字格式化后的值i18n.decimal(28.3955) -> 28.396
i18n.message(id,values)id(string,required):翻译key; values(object):参数翻译文件对应的valuei18n.message('welcome',{someone:"侬"}) -> 欢迎侬
i18n.short(date)date:时间戳日期16/8/9
i18n.medium(date)date:时间戳日期2016/8/11
i18n.long(date)date:时间戳日期2016年8月11日
i18n.full(date)date:时间戳日期2016年8月11日星期四
i18n.month(date)date:时间戳几个月前(中)
i18n.day(date)date:时间戳几天前(中)
i18n.hour(date)date:时间戳几小时前(中)
i18n.minute(date)date:时间戳几分钟前(中)
i18n.seconds(date)date:时间戳几秒前(中)
i18n.shortime(date)date:时间戳时间13:58
i18n.shortime(date)date:时间戳时间13:58:29
i18n.shortime(date)date:时间戳时间下午1:58:29

附:常用语言key值对照

语言key
中文zh
英语en
日语ja
1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago