ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
345 stars 44 forks source link
es6 i18n javascript-localization localization template-literals

Stand With Ukraine

[![ttag](https://github.com/ttag-org/ttag/blob/master/website/static/img/ttag.svg)](https://ttag.js.org/) Modern javascript i18n localization library based on ES6 tagged templates and the good old GNU gettext [![travis](https://api.travis-ci.org/ttag-org/ttag.svg?master)](https://travis-ci.org/ttag-org/ttag) [![codecov](https://codecov.io/gh/ttag-org/ttag/branch/master/graph/badge.svg)](https://codecov.io/gh/ttag-org/ttag) ![downloads](https://img.shields.io/npm/dm/ttag.svg) [![NPM](https://nodei.co/npm/ttag.png?downloads=true)](https://nodei.co/npm/ttag/)

Key features

Usage example

import { t, ngettext, msgid } from 'ttag';

// formatted strings
const name = 'Mike';
const helloMike = t`Hello ${name}`;

// plurals (works for en locale out of the box)
const n = 5;
const msg = ngettext(msgid`${n} task left`, `${n} tasks left`, n);

Installation

npm install --save ttag

CLI

You may also need to install ttag-cli for po files manipulation.

ttag cli - https://github.com/ttag-org/ttag-cli

npm install --save-dev ttag-cli

Usage from CDN

https://unpkg.com/ttag/dist/ttag.min.js

This project is designed to work in pair with babel-plugin-ttag.
But you can also play with it without transpilation.

Support

Give a ⭐️ if this project helped you!

Useful links

Slides from talks

Talks

License

This project is licensed under the MIT license.