niGel eKe - project site

lingora

MIT License Language Build Coverage Version

Site | GitHub | API | Coverage Report

lingora is a free and open-source localization management program that analyses fluent translation file for missing or redundant translations. It also supports users of the dioxus-i18n crate.

lingora is designed primarily to be used as a command line tool, but also provides a terminal user interface.

Latest Release Downloads

cli - linux | macos | windows | tui - linux | macos | windows

Install

cargo +nightly install lingora-cli
cargo +nightly install lingora-tui

Terminology

A Canonical locale document is the master against which all other documents are compared.

Primary locale documents are documents in other locales that provide their translations from the Canonical document.

Variant locale documents are documents using the same language root as a Canonical or Primary document, but have different regions.

A “localedocument is formed from multiple files within the fluent sources paths (Lingora.toml or command line argument).

The locale of a fluent file is determined from path naming. If the file name is a locale (e.g. ./i18n/en-GB.ftl, or ./i18n/errors/en-GB.ftl) then that will be deemed the locale of its contents. If the file name is more descriptive (e.g. ./i18n/en/en-GB/errors.ftl), then its locale will be deemed to be the first parent segment which represents a valid locale according to BCP 47. In the example’s case this is en-GB, not en.

Note: A name such as ./i18n/en/en-GB/fr.ftl will be deemed french (fr), which may not be as intended.

Configuration

A Lingora.toml configuraton file is the preferred way to define the locations of the fluent files within the development environment. Each of the settings within the file can be overidden (or provided solely) by command line arguments at runtime.

The Lingora.toml defines:

If the Lingora.toml file exists in the current working directory then it will be used. An explicit config file can be provided using the --config=path/to/your-config.toml command line argument. If no config file exists then sensible defaults will be used (see default_lingora.toml).

It is recommended that projects provide an explicit Lingora.toml file minimally specifying the Canonical translation file so that all other files are compared against it, rather than the locale of a user’s workstation, which would vary from user to user.

By default (i.e., no toml file exists, or is specified) lingora will look for the translation files in ./i18n/ and it will use <current_system_locale>.ftl as the Canonical translation file.

Command line arguments can be used to override config file settings, with --canonical path/to/canonical_file.ftl and --primary path/to/primary_file.ftl command line arguments. The canonical and primary path names are expected to use the <language>-<locale> or <language>-<script>-<locale> naming convention as described above.

Dioxus

lingora provides additional functionality for users of the dioxus-i18n crate.

Runtime

Lingora comprises two programs:

Github action

lingora-cli can be run in GitHub Actions. Example:

jobs:
  i18n:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Run Lingora
        uses: nigeleke/lingora@<version> # E.g. nigeleke/lingora@v0.4.0
        with:
          args: --config=./i18n/Lingora.toml # Optional; none or any cli args can be provided here.
          working-directory: ./i18n # Optional; default "."
          version: v0.4.0 # Optional; default "latest"

Note: the default version (latest) may result in a later version of lingora-cli running than the action version.

Note: the action is executed with a default system locale en_GB.UTF-8; this should not matter the canonical locale should be defined in config settings rather than defaulted.

Developmemt

cargo test
cargo llvm-cov
Package Description
common The main file analysis functionality, shared by the cli & tui
cli The command line interface
tui The terminal user browsing application

Build & run

cargo build
cargo run -p lingora-cli
cargo run -p lingora-tui