ojii / gettext.js

gettext in javascript for the browser, and a mo file compiler.
Other
7 stars 1 forks source link
gettext html i18n javascript

Build Status

Documentation Status

gettext.js

gettext.js provides a GNU gettext like interface for use in browsers, a MO file to JS transpiler and a webpack loader for MO files.

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

Usage

Webpack

import English from 'locales/en/LC_MESSAGES/messages.mo';

English.gettext('hello world');
English.ngettext('bug', 'bugs', 4);

Runtime

import {gettext as _, ngettext, set_catalog} from "gettextjs";

set_catalog(...);

_("hello world");
ngettext("bug", "bugs", 4);

Compile

gettextjs <input> <output> turns the input MO file int a JS file.