Open platform to collect and prioritize feedback
Better instructions for new languages.
Matt Roberts92375f30a64a
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex acfe6f791..efcf0c640 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -3,6 +3,7 @@There are many ways you can contribute to Fider.- **Send us a Pull Request** on GitHub. Make sure you read our [Getting Started](#getting-started-with-fider-codebase) guide to learn how to setup the development environment;+- **Translate Fider** to your language. See our [translation guide](/locale/README.md) to learn how to add a new language;- **Report issues** and bug reports on https://github.com/getfider/fider/issues;- **Give feedback** and vote on features you'd like to see at https://feedback.fider.io;- **Spread the word** by starring us on GitHub. Tweet about the project and show it to your friends. The more people know about Fider, the bigger the community will be and more contributions will be made;diff --git a/app/models/enum/locale.go b/app/models/enum/locale.goindex c938998ae..b6eb37916 100644--- a/app/models/enum/locale.go+++ b/app/models/enum/locale.go@@ -4,6 +4,10 @@ import ("github.com/pemistahl/lingua-go")+// This file is the single source of truth for all locale/language definitions in Fider.+// When adding a new language, update this file first, then follow the complete guide at:+// /locale/README.md+// Locale represents a supported language/locale in Fidertype Locale struct {Code string // Locale code (e.g., "pt-BR", "en")diff --git a/locale/README.md b/locale/README.mdnew file mode 100644index 000000000..2c3f64ff0--- /dev/null+++ b/locale/README.md@@ -0,0 +1,129 @@+# Adding a New Language to Fider 💪++This guide explains how to add a new language/locale to Fider.++## Overview++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.++## Step 1: Create Translation Files++1. Create a new directory in `/locale` with the locale code (e.g., `ko` for Korean, `pt-BR` for Brazilian Portuguese)++2. 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.++## Step 2: Add Locale to Backend (Go)++Edit **`app/models/enum/locale.go`**:++1. Add a new locale constant:++ ```go+ 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+ }+ ```++2. Add the new locale to the `AllLocales` slice:+ ```go+ AllLocales = []Locale{+ LocaleEnglish,+ LocalePortugueseBR,+ // ... other locales+ LocaleKorean, // Add your new locale here+ }+ ```++### Field Explanations++- **Code**: The locale code (e.g., `"en"`, `"pt-BR"`, `"ko"`)+- **Name**: Human-readable name shown in language selector+- **MessageFormatCode**: Culture code for the [messageformat](https://github.com/gotnospirit/messageformat) library (used for pluralization)+- **PostgresConfig**: PostgreSQL text search configuration name (see [PostgreSQL docs](https://www.postgresql.org/docs/current/textsearch-dictionaries.html))+ - 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+- **LinguaLanguage**: The [lingua-go](https://github.com/pemistahl/lingua-go) enum for automatic language detection+ - See lingua-go documentation for available languages+- **IsRTL**: Set to `true` for right-to-left languages (Arabic, Hebrew, Persian, etc.)++## Step 3: Add Locale to Frontend++1. Update `locale/locales.ts`++Add your locale to the `locales` object:++```typescript+const locales: { [key: string]: Locale } = {+ en: {+ text: "English",+ },+ // ... other locales+ ko: {+ text: "Korean",+ },+}+```++2. Update `lingui.config.js`++Add your locale code to the `locales` array:++```javascript+locales: ["pt-BR", "es-ES", "nl", /* ... other locales, */ "ko"],+```++3. Update `public/ssr.tsx`++Add your locale to the `messages` object for server-side rendering:++```typescript+const messages: { [key: string]: any } = {+ en: require(`../locale/en/client`),+ // ... other locales+ ko: require(`../locale/ko/client`),+}+```++## Step 4: Generate and Compile Translations++After adding the locale to all configuration files:++1. Check that everything works..++ ```bash+ make build+ ```++2. Run the server:++ ```bash+ make run+ ```++3. 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++4. Open a pull request++## When New Translation Strings Are Added++Fider uses [LinguiJS](https://lingui.dev) for i18n management. When new features are added:++1. New translation keys are automatically extracted and added to all locale files (`client.json` / `server.json`)+2. A [GitHub Action](/.github/workflows/locale.yml) uses Google Cloud Translate to automatically translate missing keys+3. 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.diff --git a/locale/locales.ts b/locale/locales.tsindex e1e9b2f7c..8d4d04f65 100644--- a/locale/locales.ts+++ b/locale/locales.ts@@ -1,9 +1,5 @@// NOTE: All locale definitions are centralized in app/models/enum/locale.go-// When adding a new locale, update app/models/enum/locale.go first, then:-// 1. Add the locale to this file-// 2. Add it to lingui.config.js-// 3. Add it to public/ssr.tsx-// 4. Generate translation files+// To add a new language, see the complete guide at /locale/README.mdinterface Locale {text: string