[go: up one dir, main page]

sailor-translate

0.3.4 • Public • Published
![](http://i.imgur.com/hjd3i9m.png)

Translate for Sailor

Build Status Dependency status Dev Dependencies Status NPM Status Gittip

Translations, translations everywhere

Install

npm install sailor-translate

Usage

translate = require 'sailor-translate'

or using sailor dependency

sailor    = require 'sailorjs'
translate = sailor.translate

API

.default()

Get the default language for the Translator

translate = new Translator
translate.default()
# => ''en' 

.lang([language])

With argument: Set up the default language to resolve a key.

translate = new Translator
translate.lang('es')
translate.lang()
# => 'es' 

Without argument: Get the actual language for the Translator.

translate = new Translator('es')
translate.lang()
# => 'es' 

.add([Objects..])

Add new object to the Translator. Object structure are based in angular-translate objects.

translate = new Translator
translate.add require './User'
translate.add require './Message'

.get([key])

Without argument: Get a list of object added.

With argument: Get a determinate key of the translator.

translate = new Translator
translate.add require './User'
translate.get('User.Username.NotFound')
# => 'Username not found.' 

First try with the language that the user can be set, later with the default language (en) and finally throw a error is don't found the key.

Additional

Is possible concatenate actions in the same object. For example.

Message = require './Message'
User    = require './User'
result = translate.add(User).lang("en").get("User.Username.Already")
# => "Username already exist." 

License

MIT © Kiko Beats

Package Sidebar

Install

npm i sailor-translate

Weekly Downloads

0

Version

0.3.4

License

MIT

Last publish

Collaborators

  • kikobeats