docs/i18n.md
Fabric supports multiple languages through its internationalization system. The system automatically detects your preferred language from environment variables and provides localized messages.
Fabric follows POSIX standards for locale detection with the following priority order:
--language or -g (highest priority)en) if none are set or valid# Use explicit language flag
fabric --language es --pattern summarize
# Use LC_ALL environment variable
LC_ALL=fr_FR.UTF-8 fabric --pattern summarize
# Use LANG environment variable
LANG=de_DE.UTF-8 fabric --pattern summarize
# Multiple environment variables (LC_ALL takes priority)
LC_ALL=es_ES.UTF-8 LANG=fr_FR.UTF-8 fabric --pattern summarize
# Uses Spanish (es_ES) because LC_ALL has higher priority
The system automatically normalizes various locale formats:
en_US.UTF-8 → en-USfr_FR@euro → fr-FRzh_CN.GB2312 → zh-CNde_DE.UTF-8@traditional → de-DESpecial cases:
C or POSIX → treated as invalid, falls back to EnglishTranslations are loaded from multiple sources in this order:
Embedded files (highest priority): Compiled into the binary
internal/i18n/locales/*.jsonUser config directory: Downloaded on demand
~/.config/fabric/locales/GitHub repository: Source for downloads
https://raw.githubusercontent.com/danielmiessler/Fabric/main/internal/i18n/locales/en): Default language, always availablees): Available in embedded filesTo add support for a new language:
Create a new JSON file: internal/i18n/locales/{lang}.json
Add translations in the format:
{
"message_id": "localized message text"
}
Rebuild Fabric to embed the new translations
Translation files use JSON format with message IDs as keys:
{
"html_readability_error": "use original input, because can't apply html readability"
}
Spanish example:
{
"html_readability_error": "usa la entrada original, porque no se puede aplicar la legibilidad de html"
}
The i18n system is designed to be robust:
Error messages are logged to stderr but don't prevent operation.
# Set system-wide locale
export LANG=en_US.UTF-8
# Override all locale categories
export LC_ALL=fr_FR.UTF-8
# Set only message locale (for this session)
LC_MESSAGES=es_ES.UTF-8 fabric --pattern summarize
# Check current locale settings
locale
You can test locale detection without changing your system settings:
# Test with French
LC_ALL=fr_FR.UTF-8 fabric --version
# Test with Spanish (if available)
LC_ALL=es_ES.UTF-8 fabric --version
# Test with German (will download if available)
LC_ALL=de_DE.UTF-8 fabric --version
This is normal when requesting a language not yet available. The system will fall back to English.
Check your environment variables:
echo $LC_ALL
echo $LC_MESSAGES
echo $LANG
Ensure they're in a valid format like en_US.UTF-8 or fr_FR.
Remember the priority order:
--language flag overrides everythingLC_ALL overrides LC_MESSAGES and LANGLC_MESSAGES overrides LANGThe locale detection system:
golang.org/x/text/language for parsing and validationFor developers working on the codebase, see the implementation in:
internal/i18n/locale.go: Locale detection logicinternal/i18n/i18n.go: Main i18n initializationinternal/i18n/locale_test.go: Test suite