0.3.4 • Published 10 years ago

sailor-translate v0.3.4

Weekly downloads
11
License
MIT
Repository
github
Last release
10 years ago

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

0.3.4

10 years ago

0.3.3

10 years ago

0.3.0

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago