Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including diet-dictionary with all npm packages installed. Try it out:

var dietDictionary = require("diet-dictionary")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

diet-dictionary v0.0.5

Translation Engine for Dietjs

Diet: Dictionary

With the dictionary module you can translate your app into any language using the echo() function and the dictionary table inside your mysql database.


If you have diet then it's already installed.

npm install diet-dictionary


  1. Make sure you have mysql installed
  2. Make sure you have diet installed
  3. Make sure you have correct mysql configuration when you initialize your diet app
  4. Create a dictionary table inside your mysql database

Example dictionary table

If you want to support more languages just create a new column for it and restart the server.

How are you?Hogy vagy?¿Cómo estás?

Example Backend Usage

var app = new Application(options);

app.get('/', function(request, response, mysql){
    // DEFINE language
    response.head.language = 'Hungarian';
    // Translate string
    response.head.title = response.head.echo('Hello World');
    // End HTTP Response
    response.end(response.head.title); // -> outputs "Üdv Világ!"

Example Usage in HTML

<!DOCTYPE html/>
        <title>{{-echo @title}}</title><!-- outputs: "Üdv Világ" -->
        <h1>{{-echo @title}}</h1> <!-- outputs: "Üdv Világ" -->
        <p>{{-echo 'How are you?'}}</p> <!-- outputs: "Hogy vagy?" -->

Example Usage in Client Side JS

You will need to include the dictionary.js files which is autogenerated for you in:


This is how it looks like:

<!DOCTYPE html/>
        <title>Piece of Cake</title>
        <!-- Just Include the Auto Generated dictionary.js file -->
        <script src="/scripts/dictionary.js"></script>
        <!-- Then start using the echo function to translate things -->
            var message = echo('Hello World');
            alert(message); // alerts: "Üdv Világ"
    <body>diet is awesome</body>

You can see what's the current language in window.language set within dictionary.js. You can change the language by changing response.head.language in html and response.cookies.set('language', 'yourLanguage') for client side javacsript.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free