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

@daai/i18n

v1.0.4

Published

Javascript i18n core

Downloads

29

Readme

i18n

Installation

...
<head>
<script type="text/javascript" src="i18n.min.js"></script>
</head>
...

Configure

i18n.set({
  'lang': '"ISO639-1-ISO3166-1" language code', //e.g. en-us, zh-tw. Default is auto detect from browser.
  'path': 'language file\'s path' // Default is empty (same level as i18n.js)
});

Usage


var s = i18n.t('LANGUAGE ID');
var s = i18n.datetime();
var s = i18n.datetime('Date time');

Language file

File contents in JSON format

{
    "setting": {
        "DST": 8,
        "format": "Y 年 m 月 d 日 (l) H:i:s",
        "AM": "上午",
        "PM": "下午"
    },
    "shortMonths": ["1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", "11 月", "12 月"],
    "longMonths": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
    "shortDays": ["日", "一", "二", "三", "四", "五", "六"],
    "longDays": ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],

    "Hello World": "世界您好!",
    "Hello %1, Nice to meet you": "你好 %1, 很高興認識您",
    "KEY": {
        "ID": "........"
    }
}

Filename rule

Filename must be same as language code. e.g. zh-tw.js, zh-cn.js...

Examples

String

// Use above JSON content.

// String without variables.
i18n.t('Hellow World');
// return 您好世界!

// String with variables.
i18n.t('Hello %1, Nice to meet you', 'John');
// return 你好 John, 很高興認識你

i18n.t('KEY.ID');
i18n.t('KEY.ID', 'hello');
// Nested

Date time

i18n.datetime();
// return Current datetime

i18n.datetime('2020-10-30 12:00:00');
// return '2020 年 10 月 30 日 12:00:00' datetime format.

License

i18n was release under MIT License.