ttag
ttag
⚠️ This project was previously named
c-3po
. Some of the talks, presentations, and documentation may reference it with both names.
Modern javascript i18n localization library based on ES6 tagged templates and the good old GNU gettext
Key features
- Uses ES6 template literals for string formatting (no need for sprintf).
- Contexts support
- It can precompile translations on a build step.
- Plurals support ngettext.
- It can be integrated in any build tool that works with babel.
- Has a builtin validation for translated strings format.
- It can use any default locale in sources (not only English).
- Handles React (jsx) translations.
- Can be easily integrated with Create React App. CRA doc
Usage example
// formatted stringsconst name = 'Mike';const helloMike = t`Hello `; // plurals (works for en locale out of the box)const n = 5;const msg =
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.