Skip to content

Internationalization (i18n)

LibreFolio supports multiple languages to ensure accessibility for a global audience. The frontend uses svelte-i18n for managing translations and locale switching.

Supported Languages

Currently, the following languages are supported:

  • ๐Ÿ‡ฌ๐Ÿ‡ง English (en) - Default
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian (it)
  • ๐Ÿ‡ซ๐Ÿ‡ท French (fr)
  • ๐Ÿ‡ช๐Ÿ‡ธ Spanish (es)

Architecture

Translations are stored in JSON files located in src/lib/i18n/.

src/lib/i18n/
โ”œโ”€โ”€ en.json    # Source of truth
โ”œโ”€โ”€ it.json
โ”œโ”€โ”€ fr.json
โ”œโ”€โ”€ es.json
โ””โ”€โ”€ index.ts   # Configuration and initialization

Usage in Components

To use translations in Svelte components, import the t store:

<script>
  import { t } from '$lib/i18n';
</script>

<h1>{$t('dashboard.welcome')}</h1>
<p>{$t('common.save')}</p>

Dynamic Values

You can pass variables to translation strings:

// en.json
{
  "greeting": "Hello, {name}!"
}
<p>{$t('greeting', { name: 'Alice' })}</p>

Managing Translations

We provide a CLI tool to help manage translations and ensure consistency.

Audit Missing Keys

To check for missing translations across all language files:

./dev.py i18n audit

Adding a New Key

To add a new key to all language files simultaneously:

./dev.py i18n add "dashboard.new_feature" --en "New Feature" --it "Nuova Funzionalitร " ...

Updating a Key

To update an existing key:

./dev.py i18n update "dashboard.title" --en "My Dashboard"