c-3po


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).
  • Can precompile translations on a build step.
  • Uses babel plugin to extract and resolve translations, works with modern javascript AST.
  • 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.
  • Can use any default locale in sources (not only English).
  • Handles React (jsx) translations.

Tools:

The whole solution consists of 2 parts:

  1. c-3po library - https://github.com/c-3po-org/c-3po
  2. c-3po babel plugin - https://github.com/c-3po-org/babel-plugin-c-3po

How it looks like in the code:

Here is a usage of some c-3po functions:

import { t, nt, ngettext, msgid } from 'c-3po'

// simple string literals
const hello = t`Hello c-3po`;

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

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

c-3po library aims to provide the most natural and reliable way to translate strings in a javascript sources. it provides some helper functions (tags) for making javascript templates translatable with all their shiny features like string interpolation, multiline e.t.c.

Tutorials

Slides from talks

results matching ""

    No results matching ""