Saltar a contenido

🌍 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