ttag

ttag

  • Docs
  • Blog
  • Github

›Features

Getting Started

  • Installation
  • Quick start
  • Webpack integration
  • Typescript
  • Create React App
  • Gatsby
  • Next

Tags and Functions

  • t (gettext tag)
  • jt (jsx gettext)
  • c (context)
  • ngettext (plurals)
  • gettext

Features

  • Translations validation
  • Aliasing
  • Multiline strings
  • Comments for translators
  • Ignoring code blocks

API

  • ttag API
  • babel-plugin-ttag API

CHANGELOG

  • Changelog

Multiline strings

ttag provides reliable approach for working with multiline strings. For instance if we have this in our code:

import { t } from 'ttag';

function test(name) {
    return t`multi line string
      with multiple line breaks and
      with formatting ${name}`;
}

By default the quoted phrase will contain all indentation before each line, and all those tabs will be inside the .po files and in a user content. To make things little bit easier, ttag removes all indentation before lines. So you will receive this in .po file:

#: src/multiline.js:7
msgid ""
"multi line string\n
"with multiple line breaks and\n
"with formatting"
msgstr ""

This behaviour can be changed with dedent configuration.

{
    dedent: false;
}
← AliasingComments for translators →
ttag
Docs
Quick Startttag APIbabel-plugin-ttag API
Community
User ShowcaseStack OverflowTwitter
More
BlogGitHubStar
Copyright © 2024 ttag