docs/i18n-variants.md
As of this update, Fabric supports Portuguese language variants:
pt-BR - Brazilian Portuguesept-PT - European Portuguesept - defaults to pt-BR for backward compatibilityThe i18n system supports language variants through:
Based on user demographics and linguistic differences, these variants would provide the most value:
Chinese Variants
zh-CN - Simplified Chinese (Mainland China)zh-TW - Traditional Chinese (Taiwan)zh-HK - Traditional Chinese (Hong Kong)zh → zh-CNSpanish Variants
es-ES - European Spanish (Spain)es-MX - Mexican Spanishes-AR - Argentinian Spanishes → es-ESEnglish Variants
en-US - American Englishen-GB - British Englishen-AU - Australian Englishen → en-USFrench Variants
fr-FR - France Frenchfr-CA - Canadian Frenchfr → fr-FRArabic Variants
ar-SA - Saudi Arabic (Modern Standard)ar-EG - Egyptian Arabicar → ar-SAGerman Variants
de-DE - Germany Germande-AT - Austrian Germande-CH - Swiss Germande → de-DEWhen adding new language variants:
Determine the Base: Decide which variant should be the default
Create Variant Files: Copy base file and adjust for regional differences
Update Default Map: Add to defaultLanguageVariants if needed
Focus on Key Differences:
Test Thoroughly: Ensure fallback chain works correctly
To add a new language variant:
Copy the base language file:
cp locales/es.json locales/es-MX.json
Adjust translations for regional differences
If this is the first variant for a language, update i18n.go:
var defaultLanguageVariants = map[string]string{
"pt": "pt-BR",
"es": "es-MX", // Add if Mexican Spanish should be default
}
Add tests for the new variant
Update documentation
Follow BCP 47 standards:
Input normalization handles various formats, but files and internal references should use BCP 47.
Test each variant with:
# Direct specification
fabric --help -g=pt-BR
fabric --help -g=pt-PT
# Environment variable
LANG=pt_BR.UTF-8 fabric --help
# Fallback behavior
fabric --help -g=pt # Should use pt-BR
When updating translations: