:orange_book: simple approach for javascript localization
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);
npm install --save ttag
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
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.
Give a ⭐️ if this project helped you!
This project is licensed under the MIT license.