0.0.8 • Published 11 years ago
sails-hook-dust-i18n v0.0.8
sails-hook-dust-i18n
Dust.js (Linkedin) helpers that works with Sails JS default i18n hook
Installation
- Make sure your Sails app. use Dust.js as template engine
- Install this hook by
npm install sails-hook-dust-i18n
Helpers Included
i18n(can also called by__)execsee reference here
Usage
requires at least sails >= 0.11
There are 2 option that describe main text:
Put text in body block, example:
{@i18n}Welcome{/i18n}or{@__}Welcome{/__}(bothi18nand__has same functionality)Put in
tparameter, example:{@i18n t="Welcome" /}or{@__ t="Welcome" /}Put arguments in
argsparameter if needed, example:{@i18n args="['guys']" }Welcome %s{/i18n}will rendered toWelcomen guysif locales catalog is like{"Welcome %s": "Welcomen %s"}- Make sure to define translation in
/config/locales/[locale].jslike/config/locales/en.js - That file contains translation in JSON format like
{ "Welcome": "Welcome to Sails!" }
References
- Sails i18n documentation
- Node-i18n (dependency that sails-hook-i18n rely on)
Todo
- Make body block rendering synchronously (look at index.js)
- Add test case, it always thrown an error
Error: Cannot find module '../../../../sails-hooks' - You suggest ...
License
MIT