Git Product home page Git Product logo

i18n4v's Introduction

i18n for Virtual DOM (i18n4v)

Build Status

$ npm install i18n4v --save

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

It has the following features:

  • It supports standard internatinalization features:
    • Replacing words by key (original words can be used as keys too)
    • Pluralisation
    • Formatting
    • Selecting translations from context (like gender)
  • Small runtime:
    • Runtime is written in ES3 and just 1.8kb (minified and gzipped)
    • Runtime library doesn't have any dependencies.
    • It is compatible with common.js and AMD and global reading with <script> tag.
  • It can run on browser:
    • With virtual DOM (in JavaScript)
    • With static HTML text
  • It can run on node.js:
    • To make off-line unittesting easy
    • To support server side rendering and CLI tools
  • It provides CLI tool to maintain translations

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

Document

https://i18n4v.js.org/

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

Repository

https://github.com/shibukawa/i18n4v

i18n4v's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.