Skip to content

adamchainz/gettext.js

 
 

Repository files navigation

image

Documentation Status

gettext.js

GNU gettext in Javascript. Compile your mo files to JSON/JS and then use them directly from Javascript in your browser.

Demo: https://cdn.rawgit.com/ojii/gettext.js/master/demo/index.html

Docs: http://gettextjs.readthedocs.org/

Usage

Compiling

Usage:
    gettextjs [-i] [-v] [--js] <locale-path> [<out-dir>]

Options:
    -h --help       Show this screen.
    --version       Show version.
    -i --indent     Indent JSON file.
    -v --verbose    Print stuff while doing work.
    --js            Compile to JS instead of JSON.

Javascript

Async from JSON

Gettext.load('/base/url/to/locale', 'en', 'messages').then(function(gettext){
    var msgstr = gettext.gettext('msgid');
});

Sync from JS

var gettext = new Gettext(EN_MESSAGES);
var msgstr = gettext.gettext('msgid');

About

gettext in javascript for the browser, and a mo file compiler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • JavaScript 85.4%
  • Python 8.9%
  • CSS 3.8%
  • HTML 1.9%