Skip to content

Latest commit

 

History

101 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Translator

Easy and simple translations with support for localization

Typst Universe version GitHub development branch version

Get Manual Usage tips Example PDF Example source code Changelog file Contribute with development

General tests badge Build test badge Spellcheck test badge Plugin build badge

Quick Start

#import "@preview/transl:0.2.1": 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 forked from this excellent package.

About

Easy and simple translations for words and expressions, with support for localization

Topics

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages