Skip to content
Luis Eduardo Brito edited this page Sep 25, 2013 · 1 revision

The language class is defined in the ./language/index.js````and is used to access language strings defines as JSON files or Node Modules. SO you can create a file named en-US.json``` as follow:

{
    "error": "Error",
    "help": "Help Center"
}

And access it using:

var lang = require("./language").getDefault();
console.log(lang.help); // prints 'Help Center'

The default language is specified in the /config/general.js.

Methods

  • get(lang):

    • lang: Language name. Example: for en-US.json, use 'en-US'

    Returns an object with the language strings from the JSON

  • getDefault():

    Returns an object with the language strings from the JSON defined in the /config/general.js default language.

  • val(string_id, [args,...]):

    • string_id: id for the language string to select from json.

    Example: en-US.json

    {
      "error": {
        "unknown": "Unknown error: %s"
      }
    }

    In the javascript, you can use val() as follows:

    var lang = require("./language");
    console.log(lang.val("error.unknown", "Sample error"));
    // prints: 'Unknown error: Sample error'
Clone this wiki locally