Lingu Translate Configuration

The Lingu configuration file is the foundation to speed up your workflow with the Lingu CLI.
By default, the easiest way to work with Lingu CLI is to place your configuration in the root directory of your project named .lingu.yml

Basics

The following is an example of a Lingu configuration file that shows the basic configuration options.

# Location of your lingu file
# - Imports from your localization files will be stored here
# - Exports to your localization files are based on this file
lingu: Lingu Translations.lingu

# The locales you want to be handled by lingu cli
# Only the locales from this list will be imported/exported
locales:
  - de
  - en

# Import section
import:
  # Your localization files you want to import
  files:
    - path: LinguApp/{LOCALE}.lproj/Main.strings # absolute or relative file path
      format: apple_strings                      # format of your file (see formats)
      tag: Main.strings                          # tag(s) you want to assign on import
    - path: LinguApp/{LOCALE}.lproj/Localizable.strings
      format: apple_strings
      tag: Localizable.strings
    - path: LinguApp/Import/{LOCALE}.lproj/Import.strings
      format: apple_strings
      tag: Import.strings

export:
  files:
    - path: LinguApp/{LOCALE}.lproj/Main.strings
      format: apple_strings
      tag: Main.strings
    - path: LinguApp/{LOCALE}.lproj/Localizable.strings
      format: apple_strings
      tag: Localizable.strings
    - path: LinguApp/Import/{LOCALE}.lproj/Import.strings
      format: apple_strings
      tag: Import.strings

Locale Aliases

Sometimes it happens that the locale identifiers in your project files are different from those in Lingu. For example, if you “just want to translate Portuguese” in Lingu and don’t want to differentiate between Portuguese Portuguese (pt-PT) and Brazilian Portuguese (pt-BR).

In this case you can teach Lingu CLI to pull the texts for Portuguese from another file, by adding the locale_aliases section as seen below.

import:
  files:
    - path: LinguApp/{LOCALE}.lproj/Main.strings
      format: apple_strings
      tag: Main.strings
  locale_aliases:
    zh: "zh-Hans"
    pt: "pt-PT"
# lingu cli will import files from folders named zh-Hans.lproj and pt-PT.lproj instead of zh.lproj and pt.lproj

Locale Mapping

Locale Mapping is the inverted form of Locale Aliases. For Example in Lingu you want to manage your Portuguese texts with the locale “pt” but you want to export these Portuguese texts to multiple files “pt-PT” and “pt-BR”.

export:
  files:
    - path: LinguApp/{LOCALE}.lproj/Main.strings
      format: apple_strings
      tag: Main.strings
  locale_mapping:
    zh:
      - "zh-Hans"
    pt:
      - "pt-PT"
      - "pt-BR"
# lingu cli will export files to pt-PT.lproj AND pt-BR.lproj, both with content from your locale "pt"
# instead of just exporting it to pt.lproj