https://github.com/typst-community/linguify
typst package to load strings for different languages easily.
https://github.com/typst-community/linguify
internationalization localization typst typst-package
Last synced: 12 months ago
JSON representation
typst package to load strings for different languages easily.
- Host: GitHub
- URL: https://github.com/typst-community/linguify
- Owner: typst-community
- License: mit
- Created: 2024-01-30T22:22:44.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-05T21:54:08.000Z (about 1 year ago)
- Last Synced: 2025-04-01T15:58:11.829Z (12 months ago)
- Topics: internationalization, localization, typst, typst-package
- Language: Typst
- Homepage: https://typst.app/universe/package/linguify
- Size: 1.2 MB
- Stars: 26
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```typst
#import "@preview/linguify:0.4.2": *
#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:
```toml
[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:
```typ
#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](https://projectfluent.org) support