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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-i18n

v2.0.0

Published

i18n module for Hexo.

Downloads

62,484

Readme

hexo-i18n

Build Status NPM version Coverage Status

i18n module for Hexo.

Installation

$ npm install hexo-i18n --save

Usage

Example

var i18n = new require('hexo-i18n')({
  languages: ['zh-TW', 'en']
});

i18n.set('en', {
  ok: 'OK',
  name: 'My name is %1$s %2$s.',
  index: {
    title: 'Home'
  },
  video: {
    zero: 'No videos',
    one: 'A video',
    other: '%d videos'
  }
});

i18n.set('zh-TW', {
  name: '我的名字是 %2$s %1$s。',
  index: {
    title: '首頁'
  },
  video: {
    zero: '沒有影片',
    one: '一部影片',
    other: '%d 部影片'
  }
});

var __ = i18n.__();
var _p = i18n._p();

__('ok') // OK
__('index.title') // 首頁
__('name', '大呆', '王') // 我的名字是王大呆
_p('video', 0) // 沒有影片
_p('video', 1) // 一部影片
_p('video', 10) // 10 部影片

new i18n([options])

Creates a new i18n instance.

Option | Description | Default --- | --- | --- languages | Default languages. It can be an array or a string | default

i18n.get([lang]) → Object

Returns a set of localization data. lang can be an array or a string, or the default language defined in constructor if not set. This method will build the data in order of languages.

i18n.set(lang, data)

Loads localization data.

i18n.remove(lang)

Unloads localization data.

i18n.list()

Lists loaded languages.

i18n.__() → Function(key, arg...)

Returns a function for localization.

i18n._p() → Function(key, count, ...)

This method is similar to i18n.__, but it returns pluralized string based on the second parameter. For example:

_p('video', 0) = __('video.zero', 0)
_p('video', 1) = __('video.one', 1)
_p('video', 10) = __('video.other', 10)

License

MIT