Coder Social home page Coder Social logo

translator-helper-dustjs's Introduction

translator-helper-dustjs Dependency Status

A little helper for dustjs to load i18n translations dynamically, with variables, based on https://github.com/mikesparr/Kraken_Example_i18n_Helper. Feel free to comment, copy or burn this code =P

New version supporting kraken 2. Check the 1.x for kraken 1 and 2.x for kraken 2.

Getting Started

Install the module with: npm install translator-helper-dustjs

Its important to add a global variable to pass the kraken config to the module, i put in my index.js this after load kraken config

/* ... */
app = module.exports = express();
app.use(kraken(options));
global._app = app;
/* ... */
KrakenJs 2
/* ... */
//In your config file, using tag 2.x
    "dust": {
        "helpers": [
            "dust-makara-helpers",
            "translator-helper-dustjs"
        ]
    },
/* ... */
KrakenJs 1
/* ... */
// On your controllers file or wethever you load dust, add the helper like another, using tag 1.x
var dust = require('dustjs-linkedin');
require('dustjs-helpers');
require('translator-helper-dustjs');
/* ... */

Examples

On your properties files (index.properties)

/* ... */
jobs.acme.title=Company Acme
jobs.hernes.title=Company Hernes
/* ... */

On your dust template files, pass to the t helper the key (jobs.acme.title -> companyName = "acme"), the properties file (index in this case), and the lang (in my case "EN_us")

/* ... */
{@t key="jobs.{companyName}.title" bundle="index" lang="{lang}" /}
/* ... */

And the result will be

/* ... */
Company Acme
/* ... */

Contributing

Please fell free to contribute, i´m not a real expert of dustJs

Release History

###(2.x)

  • Supporting krakenJs 2

###(1.x)

  • Supporting krakenJs 1

License

Copyright (c) 2015 Daniel Biedma Ramos Licensed under the MIT license.

translator-helper-dustjs's People

Contributors

danibram avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.