This guide explains how to add a new language/locale to Fider.
All locale definitions are centralized in app/models/enum/locale.go. This is the single source of truth for backend locale metadata including locale codes, display names, pluralization rules, PostgreSQL text search configurations, and language detection mappings.
-
Create a new directory in
/localewith the locale code (e.g.,kofor Korean,pt-BRfor Brazilian Portuguese) -
Create two JSON files in the new directory:
client.json- Frontend translations (UI strings)server.json- Backend translations (emails, server-side messages)
The easiest way to do this is copy the english files, and remove all the translations, replacing them with ones in your language.
Edit app/models/enum/locale.go:
-
Add a new locale constant:
LocaleKorean = Locale{ Code: "ko", // Locale code Name: "Korean", // Display name MessageFormatCode: "ko", // Pluralization library culture code PostgresConfig: "simple", // PostgreSQL text search config LinguaLanguage: lingua.Korean, // Lingua-go language enum IsRTL: false, // Right-to-left text direction }
-
Add the new locale to the
AllLocalesslice:AllLocales = []Locale{ LocaleEnglish, LocalePortugueseBR, // ... other locales LocaleKorean, // Add your new locale here }
- Code: The locale code (e.g.,
"en","pt-BR","ko") - Name: Human-readable name shown in language selector
- MessageFormatCode: Culture code for the messageformat library (used for pluralization)
- PostgresConfig: PostgreSQL text search configuration name (see PostgreSQL docs)
- Available configs:
"english","german","french","spanish","portuguese","italian","dutch","russian","swedish","turkish","arabic" - Use
"simple"if PostgreSQL doesn't have native support for your language
- Available configs:
- LinguaLanguage: The lingua-go enum for automatic language detection
- See lingua-go documentation for available languages
- IsRTL: Set to
truefor right-to-left languages (Arabic, Hebrew, Persian, etc.)
- Update
locale/locales.ts
Add your locale to the locales object:
const locales: { [key: string]: Locale } = {
en: {
text: "English",
},
// ... other locales
ko: {
text: "Korean",
},
}- Update
lingui.config.js
Add your locale code to the locales array:
locales: ["pt-BR", "es-ES", "nl", /* ... other locales, */ "ko"],- Update
public/ssr.tsx
Add your locale to the messages object for server-side rendering:
const messages: { [key: string]: any } = {
en: require(`../locale/en/client`),
// ... other locales
ko: require(`../locale/ko/client`),
}After adding the locale to all configuration files:
-
Check that everything works..
make build
-
Run the server:
make run
-
Verify:
- The new language appears in the language selector
- Translations display correctly
- Right-to-left rendering works (if applicable)
- Search functionality works with the correct PostgreSQL configuration
-
Open a pull request
Fider uses LinguiJS for i18n management. When new features are added:
- New translation keys are automatically extracted and added to all locale files (
client.json/server.json) - A GitHub Action uses Google Cloud Translate to automatically translate missing keys
- Machine translations are submitted as a pull request for review
While the automated translations work well for most cases, you may want to refine them for accuracy and cultural context. Feel free to submit pull requests with improved translations at any time.