Universe

Manual Tips Example PDF Example SRC Changelog Contribute

Quick Start

#import "@preview/transl:0.2.0": transl
#set text(lang: "es")

#transl(data: yaml("database.yaml"))

#transl("I love you")

#show: transl.with("love")

Description

Get comprehensive and localized translations, with support for regular expressions and Fluent files. This package comes with only one #transl command used to both set the translation database and retrieve translations.

The expressions are the texts to be translated; they can be words, phrases, or regular expression strings. Multiple expressions can be used in a single command, where each one will be retrieved and concatenated (separated by space).

Feature List

  • Automatic translation to #text.lang language
  • Support for #text.region
  • Language id notation (lang-REGION)
  • Robust translation formats
    • YAML/TOML (multilingual)
    • Fluent markup (single language)
    • YAML/TOML + Fluent (multilingual)
  • Support for #show rules
  • Regular expressions
  • Multiple ways to obtain values
    • Retrieve opaque #context() values
    • Retrieve context-dependent strings
    • Retrieve plain strings
  • Localization arguments
    • Standard databases (basic)
    • Fluent databases

Translation databases

The command needs to be fed with translation database files to function correctly. These databases can be written in YAML/TOML and/or Fluent each.

Standard databases

l10n: std
lang:
  expression: Translation

Allows to define translations for expressions in various languages. Set as:

#transl(data: yaml("std.yaml"))

Fluent databases

l10n: ftl
lang: |
  identifier = Translation

Allows to define multiple Fluent files (as strings) with translations for various languages. Set as:

#transl(data: yaml("ftl.yaml"))

Fluent files

identifier = Translation

Allows to define an individual Fluent file with translations for a single language. Set as:

#transl(data: read("xy.ftl"), lang: "xy")

Although written from scratch, the conceptual structure of the package is heavily inspired by the linguify package; the Fluent WASM plugin was derived from this excellent package.