Code Monkey home page Code Monkey logo

i18n-utils's Introduction

i18n-utils

The i18n tag function utilitities (WIP)

donate License: ISC

Related post.

Quick Introduction

If you'd like to make your code i18n ready you can use the i18n-dummy module which provides a noop function tag.

// anywhere you need to write future proof code
// use template literals and put i18n in front
const greetings = i18n`Hello ${user.name}!`;

Once you have put the i18n function tag in front of all sentences that need translations, you can install this utility and point at the main entry point of your program:

# you could use -g too
npm install i18n-utils

# if you have latest npm use the binary
npx i18n-utils src/main.js

At this point you just need to follow instructions until a browser page opens, giving you all the found sentences that need translation in other languages you've specified.

Once you've translated all languages you can install and use i18n-yummy function which expects a runtime locale and a database to use.

Specify both and see that changing locale will produce automatically sentences in the different language.

test.js example

// somehow include the client library
const i18n = require('i18n-yummy');

// specify the locale to display
// and the database to use
i18n.locale = 'it';
i18n.db = require('./i18n.db.json');

// write content in the language you used
// as default to setup the database (en)
console.log(i18n`Hello ${'i18n'}!`);

Try to save above file as test.js and then i18n-utils ./test.js providing it as translation language and writing Ciao instead of Hello in the dedicated area.

If you'll node test.js after you will see the output will be Ciao i18n! instead of Hello i18n!.

i18n-utils's People

Contributors

webreflection avatar

Watchers

 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.