Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
translation utility
JavaScript
Branch: master

Merge pull request #8 from component/cache

create and cache a reusable function
latest commit 9aa69174a9
@Swatinem Swatinem authored
Failed to load latest commit information.
test create and cache a reusable function
.gitignore Initial commit
History.md Release 1.0.0
Makefile Initial commit
Readme.md add language override
component.json Release 1.0.0
index.js
package.json Release 1.0.0

Readme.md

t

tiny translation helper.

Installation

$ component install component/t

API

t(string, [object], [lang])

Return a translatable string, with optional substitutions keyed in object using language lang.

var t = require('t');

t('Hello');
// => "Hello"

t('Hello {name}', { name: 'Tobi' });
// => "Hello Tobi"

t.lang()

Get the current language code, for example "en".

t.lang(code)

Set language code.

t.CODE = object

Define translations, for example:

t.es = {
  'Hello {name}': 'Hola {name}'
};

t('Hello {name}', { name: 'Tobi' });
// => "Hello Tobi"

t.lang('es');
t('Hello {name}', { name: 'Tobi' }).should.equal('Hola Tobi');
// => "Hola Tobi"

License

MIT

Something went wrong with that request. Please try again.