| Crates.io | elm-i18n |
| lib.rs | elm-i18n |
| version | 0.5.4 |
| created_at | 2025-11-16 11:48:17.326502+00 |
| updated_at | 2026-01-19 12:30:57.921101+00 |
| description | CLI tool for managing Elm I18n translations |
| homepage | https://github.com/charles-andre-assus/elm-i18n |
| repository | https://github.com/charles-andre-assus/elm-i18n |
| max_upload_size | |
| id | 1935430 |
| size | 204,970 |
A command-line tool for managing internationalization (i18n) translations in Elm applications.
cd elm-i18n-cli
./install.sh
This will:
~/.local/bin or /usr/local/bin# Build in release mode
cargo build --release
# Copy to a directory in your PATH
cp target/release/elm-i18n ~/.local/bin/
# OR
sudo cp target/release/elm-i18n /usr/local/bin/
cargo install --path .
./uninstall.sh
elm-i18n setup
This interactive command creates an elm-i18n.json configuration file. Choose between:
elm-i18n status
Shows your current configuration, available shortcuts, and usage examples.
elm-i18n init
# Creates src/I18n.elm with English and French support
elm-i18n init --languages en,fr,es
# Creates with custom language support
elm-i18n add welcomeBack --fr "Bon retour" --en "Welcome back"
If the key already exists, it will show the current translations:
ℹ Translation 'welcome' already exists:
EN: Welcome to your Lamdera application!
FR: Bienvenue dans votre application Lamdera!
The existing translations might be sufficient. Consider using a different key.
NEW: Use the --replace flag to automatically find and replace hardcoded strings in your codebase:
elm-i18n add youAreWelcome --fr="De rien" --en="You are welcome" --replace
This will:
t.youAreWelcomeNote: You'll need to ensure t (translations) is passed as a parameter to your views. The compiler will guide you through any necessary changes.
Example output:
✓ Added translation 'youAreWelcome' to src/I18n.elm
EN: You are welcome
FR: De rien
🔍 Searching for hardcoded strings to replace...
✓ Found 2 occurrences of "You are welcome":
src/Main.elm:10:
, p [] [ text "You are welcome" ]
src/Main.elm:13:
[ text "You are welcome"
✓ Found 2 occurrences of "De rien":
src/Main.elm:11:
, p [] [ text "De rien" ]
src/Main.elm:15:
, text "De rien"
🔄 Replacing strings with t.youAreWelcome...
✓ Replaced 4 occurrences across 1 file(s)
Options for --replace:
--src-dir: Directory to search for replacements (default: "src")For translations that require parameters or complex logic:
# Simple function with parameter
elm-i18n add-fn selected \
--type-sig "Int -> String" \
--en "\count -> String.fromInt count ++ \" selected\"" \
--fr "\count -> String.fromInt count ++ \" sélectionné(s)\""
# Function with case expression (for months, categories, etc.)
elm-i18n add-fn getMonthName \
--type-sig "Int -> String" \
--en "\month -> case month of\n 1 -> \"January\"\n 2 -> \"February\"\n 3 -> \"March\"\n _ -> \"Unknown\"" \
--fr "\month -> case month of\n 1 -> \"Janvier\"\n 2 -> \"Février\"\n 3 -> \"Mars\"\n _ -> \"Inconnu\""
# Function for ticket categories
elm-i18n add-fn ticketCategory \
--type-sig "Ticket.TicketCategory -> String" \
--en "\category -> case category of\n Ticket.Maintenance -> \"Maintenance\"\n Ticket.Cleaning -> \"Cleaning\"\n Ticket.Other _ -> \"Other\"" \
--fr "\category -> case category of\n Ticket.Maintenance -> \"Maintenance\"\n Ticket.Cleaning -> \"Nettoyage\"\n Ticket.Other _ -> \"Autre\""
elm-i18n check welcomeBack
# ✓ Translation 'welcomeBack' exists:
# EN: Welcome back
# FR: Bon retour
elm-i18n check nonExistentKey
# ✗ Translation 'nonExistentKey' not found
elm-i18n remove oldKey
# ℹ Removing translation 'oldKey':
# EN: Old text
# FR: Ancien texte
#
# ✓ Removed translation 'oldKey' from src/I18n.elm
elm-i18n list
# 📋 Found 6 translations:
# • cancel (String)
# • itemCount (Int -> String)
# • loading (String)
# • save (String)
# • ticketStatus (Ticket.Status -> String)
# • welcome (String)
elm-i18n list --verbose
# Shows full translation values for each key
elm-i18n list --filter "ticket"
# 📋 Found 1 translation:
# • ticketStatus (Ticket.Status -> String)
By default, the tool looks for src/I18n.elm. You can specify a different path:
elm-i18n add myKey --fr "Ma clé" --en "My key" --file path/to/I18n.elm
The tool:
I18n.elm fileTranslations type definitiontranslationsEn recordtranslationsFr record.bak files before modifications# Start a new project
elm-i18n init
# Add some basic translations
elm-i18n add appName --fr "Mon Application" --en "My Application"
elm-i18n add loading --fr "Chargement..." --en "Loading..."
elm-i18n add save --fr "Sauvegarder" --en "Save"
# Add a function for pluralization
elm-i18n add-fn itemCount \
--type-sig "Int -> String" \
--en "\n -> if n == 1 then \"1 item\" else String.fromInt n ++ \" items\"" \
--fr "\n -> if n == 1 then \"1 élément\" else String.fromInt n ++ \" éléments\""
# Check what you've added
elm-i18n check appName
MIT License - Copyright (c) 2025 Charles-André Assus