npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cs-i18n

v1.0.5

Published

国际化组件

Readme

[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):参数 | 翻译文件对应的value | i18n.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