Skip to content
📙 simple approach for javascript localization
Branch: master
Clone or download
Latest commit bcf13e8 Mar 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs fix changelog Mar 16, 2019
examples fixed docs links + renamed c-3po references to ttag (#147) Feb 14, 2019
src Fixed expressions substitution (#155) Mar 15, 2019
types fix(types): Upgrade dtslint and remove react typings (#140) Jan 3, 2019
website added doc for the typescript quickstart + example (#142) Jan 22, 2019
.babelrc Upgrade to babel 7 (#122) Sep 3, 2018
.eslintrc fix lint issues Sep 27, 2017
.npmignore CRA doc (#132) Nov 7, 2018
.travis.yml chore(travis): Add explicit node versions 8, 10, latest LTS and lates… Oct 23, 2018
CNAME fix CNAME for ttag Aug 8, 2018
webpack.config.js Upgrade to babel 7 (#122) Sep 3, 2018


travis codecov downloads


⚠️ 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

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 -

npm install --save-dev ttag-cli

Usage from CDN

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

Useful links


Slides from talks


You can’t perform that action at this time.