1.0.0 • Published 6 years ago

salak-i18n v1.0.0

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

salak-i18n

NPM version build status Test coverage David deps NPM download

i18n for salak 2.0

Install

$ npm install --save salak-i18n

Usage

Config

In plugin:

module.exports = {
  plugin: [
    {
      name: 'i18n',
      package: 'salak-i18n'
    }
  ]
}

options

  • root {String} locales file location, default path.join('config', 'locales')
  • defaultLocale {String} default en-US
  • queryField {String} default locale
  • cookieField {String} default locale
  • localeAlias {Object} alias for locales
  • writeCookie {Boolean} default true

Context

ctx.__(key, ...args)

alias: ctx.gettext

  • key **{String} i18n key
  • args {Array} if set, it will be call util.format

ctx.locale

return current locale

Controller

this.__(key, ...args)

alias: this.gettext

LICENSE

MIT