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

LibreFolio provides a full CLI toolkit for managing translation files via ./dev.py i18n.

๐Ÿ” Audit

Check for missing, extra, or duplicate keys across all language files:

# Basic audit โ€” missing and extra keys
./dev.py i18n audit

# Include duplicate value detection
./dev.py i18n audit --duplicates

# Output as formatted table
./dev.py i18n audit --format table

# Export audit results to Excel
./dev.py i18n audit --output report.xlsx
Flag Description
--duplicates Also report keys with identical values across languages
--format Output format (text, table)
--output FILE Save report to file (.xlsx for Excel)

โž• Add, Update, Remove Keys

# Add a new key to ALL language files
./dev.py i18n add "dashboard.new_feature" --en "New Feature" --it "Nuova Funzionalitร " --fr "Nouvelle Fonctionnalitรฉ" --es "Nueva Caracterรญstica"

# Update an existing key in specific languages
./dev.py i18n update "dashboard.title" --en "My Dashboard" --it "La mia Dashboard"

# Remove a key from all language files
./dev.py i18n remove "obsolete.key"

# Remove without confirmation prompt
./dev.py i18n remove "obsolete.key" -f

๐Ÿ”Ž Search & Explore

# Search for keys or values containing a query
./dev.py i18n search "broker"

# Search only in keys
./dev.py i18n search "broker" -k

# Search only in values
./dev.py i18n search "broker" -v

# Search in a specific language
./dev.py i18n search "courtier" -l fr

# Show key tree structure
./dev.py i18n tree

# Show tree for a prefix with key counts
./dev.py i18n tree "fx" --counts