i18n for Virtual DOM (i18n4v)

$ npm install i18n4v --save

i18n4v is an internationalization helper library for browsers and node.js.

It has the following features:

Core part of i18n is derived from roddeh-i18n. Thank you roddeh.

Do you want to use Golang on your server? Yes! You can use Golang edition of this library. You can share same translation fileas between JavaScript and Golang.

Example

Use with JavaScript:

// This sample uses with Mithril.
// You can use any virtual DOM framework.
const m = require('mithril');
const i18n = require('i18n4v');

var mithrilComponent = {
    view(ctrl) {
        return m("div", i18n("hello world");
    }
}

i18n.translator.add({
    values: {
        "hello world": "こんにちわ世界"
    }
});

Use with static HTML:

<article>
   <h1 data-i18n>Monty Python</h1>
</artice>

<script>
i18n.translator.add({
    values: {
        "Monty Python": "モンティ・パイソン"
    }
});
i18n.translator.applyToHTML();
</script>

License

MIT

Indices and tables