l

linguify

@preview

Load strings for different languages easily

v0.5.0
MIT
1 downloads

Package Information

Last Updated
Minimum Typst Version
0.11.0
Authors
Jomaway

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/linguify:0.5.0

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/linguify:0.5.0": *

Version History

0.5.00.11.0
ad525da5e5d3...
0.4.20.11.0
77644aeba1cb...
0.4.10.11.0
24099dee4958...
0.4.00.11.0
2161fec548e8...
0.3.10.11.0
284092c4d3f2...
0.3.00.11.0
d966e9db6a02...
0.2.00.11.0
a1c6e74c99d8...
0.1.00.10.0
5198ca531190...

Typst-linguify

Load strings for different languages easily. This can be useful if you create a package or template for multilingual usage.

Usage

The usage depends if you are using it inside a package or a template or in your own document.

For end users and own templates

You can use linguify global database.

Example:

#import "@preview/linguify:0.5.0": *

#let lang-data = toml("lang.toml")
#set-database(lang-data)

#set text(lang: "de")

#linguify("abstract")  // Shows "Zusammenfassung" in the document.

The lang.toml must look like this:

[conf]
default-lang = "en"

[lang.en]
title = "A simple linguify example"
abstract = "Abstract"

[lang.de]
title = "Ein einfaches Linguify Beispiel"
abstract = "Zusammenfassung"

Inside a package

So that multiple packages can use linguify simultaneously, they should contain their own database. A linguify database is just a dictionary with a certain structure. (See database structure.)

Recommend is to store the database in a separate file like lang.toml and load it inside the document. And specify it in each linguify() function call.

Example:

#import "@preview/linguify:21": *

#let database = toml("lang.toml")

#linguify("key", from: database, default: "key")

Features

  • Use a toml or other file to load strings for different languages. You need to pass a typst dictionary which follows the structure of the shown toml file.
  • Specify a default-lang. If none is specified it will default to en
  • Fallback to the default-lang if a key is not found for a certain language.
  • Fluent support