Fetching contributors…
Cannot retrieve contributors at this time
196 lines (127 sloc) 3.89 KB

Lingui Configuration

Configuration is read from 3 different sources (the first found wins):

  • from lingui section in package.json
  • from .linguirc
  • from lingui.config.js

<rootDir> is replaced with base directory of the configuration file.

Default config:

  "lingui": {
    "compileNamespace": "cjs",
    "extractBabelOptions": {},
    "fallbackLocale": "",
    "sourceLocale": "",
    "localeDir": "<rootDir>/locale",
    "srcPathDirs": [
    "srcPathIgnorePatterns": [
    "format": "lingui",
.. config:: compileNamespace


Default: cjs

Specify namespace for exporting compiled messages. See :cli:`compile` command.


Use CommonJS exports:

/* eslint-disable */module.exports={languageData: {"..."}, messages: {"..."}}


Use ES6 default export:

/* eslint-disable */export default{languageData: {"..."}, messages: {"..."}}


Assign compiled messages to window or global object. Specify an identifier after window or global to which the catalog is assigned, e.g. window.i18n.

For example, setting :conf:`compileNamespace` to window.i18n creates file similar to this:

/* eslint-disable */window.i18n={languageData: {"..."}, messages: {"..."}}
.. config:: extractBabelOptions


Default: {}

Specify extra babel options used to parse source files when messages are being extracted. Not required in most cases.

  "extractBabelOptions": {
    "plugins": ["@babel/plugin-syntax-dynamic-import"]
.. config:: fallbackLocale


Default: ''

Translation from :conf:`fallbackLocale` is used when translation for given locale is missing.

If :conf:`fallbackLocale` isn't defined or translation in :conf:`fallbackLocale` is missing too, either message default or message ID is used instead.

.. config:: format


Default: lingui

Format of message catalogs. Possible values are:


Each message is an object composed in the following format:

  "MessageID": {
    "translation": "Translated Message",
    "defaults": "Default string (from source code)",
    "origin": [
      ["path/to/src.js", 42]

Origin is filename and line number from where the message was extracted.


Simple JSON with message ID -> translation mapping:

   "MessageID": "Translated Message"


Gettext PO file:

#: src/App.js:4, src/Component.js:2
msgid "MessageID"
msgstr "Translated Message"
.. config:: sourceLocale


Default: ''

Locale of message IDs, which is used in source files. Catalog for :conf:`sourceLocale` doesn't require translated messages, because message IDs are used by default. However, it's still possible to override message ID by providing custom translation.

The difference between :conf:`fallbackLocale` and :conf:`sourceLocale` is that :conf:`fallbackLocale` is used in translation, while :conf:`sourceLocale` is used for the message ID.

.. config:: srcPathDirs


Default: [<rootDir>]

List of directories with source files from which messages are extracted. Ignored directories are defined in :conf:`srcPathIgnorePatterns`.

.. config:: srcPathIgnorePatterns


Default: ["/node_modules/"]

Ignored paths when looking for source files to extract messages from.

.. config:: localeDir


Default: <rootDir>/locale

Directory where message catalogs should be saved.