ttag-org / c-3po

Old repo for ttag (when it was named c-3po)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ttag

travis codecov

NPM

⚠️ 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 options for both efficient development and production setups.
  • Has a builtin validation for translated strings format.
  • It can use any default locale in sources (not only English).
  • Handles React (jsx) translations.

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
npm install --save-dev babel-plugin-ttag

ttag babel plugin - https://github.com/ttag-org/babel-plugin-ttag

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.

Useful links

Tutorials

Slides from talks

Talks

About

Old repo for ttag (when it was named c-3po)

License:MIT License


Languages

Language:JavaScript 100.0%