[PR #926] [MERGED] Add i18n #20534

Closed
opened 2026-04-20 03:01:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/926
Author: @asedmammad
Created: 2/26/2024
Status: Merged
Merged: 3/16/2024
Merged by: @tjbck

Base: devHead: feat/add-i18n


📝 Commits (10+)

  • fab89a7 feat: WIP: Initial setup for i18next
  • 7a77f3c feat: Change translation keys to fallback strings
  • 3c471ee feat: Migrate hardcoded strings to i18n calls
  • 511b52f feat: Add translation file for english
  • fbed07f fix: Merge similar string literals
  • 45f6908 fix: Minor fixes in english translation file
  • da02028 feat: add farsi translation file v1
  • 6d2f462 fix: add missed translations
  • 670b65c fix: add missed imports
  • 893b738 german translations + new vars

📊 Changes

68 files changed (+6909 additions, -808 deletions)

View changed files

📝 CHANGELOG.md (+10 -0)
📝 docs/CONTRIBUTING.md (+12 -0)
i18next-parser.config.ts (+38 -0)
📝 package-lock.json (+3215 -82)
📝 package.json (+6 -1)
📝 src/lib/components/AddFilesPlaceholder.svelte (+7 -2)
📝 src/lib/components/ChangelogModal.svelte (+7 -4)
📝 src/lib/components/admin/EditUserModal.svelte (+9 -7)
📝 src/lib/components/admin/Settings/Database.svelte (+6 -4)
📝 src/lib/components/admin/Settings/General.svelte (+17 -14)
📝 src/lib/components/admin/Settings/Users.svelte (+15 -11)
📝 src/lib/components/admin/SettingsModal.svelte (+7 -4)
📝 src/lib/components/chat/MessageInput.svelte (+23 -15)
📝 src/lib/components/chat/MessageInput/Documents.svelte (+8 -4)
📝 src/lib/components/chat/MessageInput/Models.svelte (+7 -3)
📝 src/lib/components/chat/MessageInput/PromptCommands.svelte (+7 -4)
📝 src/lib/components/chat/Messages.svelte (+4 -2)
📝 src/lib/components/chat/Messages/Placeholder.svelte (+5 -3)
📝 src/lib/components/chat/Messages/ResponseMessage.svelte (+6 -4)
📝 src/lib/components/chat/Messages/UserMessage.svelte (+11 -8)

...and 48 more files

📄 Description

Pull Request Checklist

  • Description: Briefly describe the changes in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?

Description

  • This pull request introduces internationalization (i18n) to the project, including the addition of a setting input to determine the UI language. When a language is selected, the user interface adjusts accordingly. Internationalization is done using i18next, and could be used in svelte files like this:
// const i18n = getContext('i18n');
$i18n.t('translation key')
  • This needs translation key to be present in translation files located at src/lib/i18n/locales for each language. Translation are specified in JSON format. Adding new translation keys to these translation files can be done either manually or by issuing the following command in the root directory of the project:
npm run i18n:parse
  • This scans js/svelte files in the src directory for translation keys and adds missing keys for available languages. Available languages are specified in src/lib/i18n/locales/languages.json.

  • Also we utilize i18next-browser-languagedetector to detect current user's language and set it in a svelte store which will update the UI with the detected language. Detection is done in this order:

  1. querystring (e.g lang=en)
  2. localStorage
  3. navigator
  • We use current string literals as translation keys, so that the keys themselves can act as fallback translation strings and also help in the process of adding translation values.

Changelog Entry

Added


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/926 **Author:** [@asedmammad](https://github.com/asedmammad) **Created:** 2/26/2024 **Status:** ✅ Merged **Merged:** 3/16/2024 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `feat/add-i18n` --- ### 📝 Commits (10+) - [`fab89a7`](https://github.com/open-webui/open-webui/commit/fab89a76b1f2852253e4e3b74127eaffdf0c8bab) feat: WIP: Initial setup for i18next - [`7a77f3c`](https://github.com/open-webui/open-webui/commit/7a77f3c2c06d19a7f588a13c48df4344dcfed73c) feat: Change translation keys to fallback strings - [`3c471ee`](https://github.com/open-webui/open-webui/commit/3c471ee2ca12749828edfa8f1b2b794cba97190a) feat: Migrate hardcoded strings to i18n calls - [`511b52f`](https://github.com/open-webui/open-webui/commit/511b52f642ed905bc89edc1e19c9a579825a7a14) feat: Add translation file for english - [`fbed07f`](https://github.com/open-webui/open-webui/commit/fbed07f65188b2845af9333103ae9e99502e17d3) fix: Merge similar string literals - [`45f6908`](https://github.com/open-webui/open-webui/commit/45f6908154536e7a52c60c0036c758c2c943e3d6) fix: Minor fixes in english translation file - [`da02028`](https://github.com/open-webui/open-webui/commit/da0202851f730170f654c8f8f93aec784abfab1b) feat: add farsi translation file v1 - [`6d2f462`](https://github.com/open-webui/open-webui/commit/6d2f4620904d7b15b0fc356c52215ea77430b909) fix: add missed translations - [`670b65c`](https://github.com/open-webui/open-webui/commit/670b65c06692bf8bc9b65756d228e6f2de0eee0b) fix: add missed imports - [`893b738`](https://github.com/open-webui/open-webui/commit/893b738cbf8204e4d346d44a56e3141582c20636) german translations + new vars ### 📊 Changes **68 files changed** (+6909 additions, -808 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+10 -0) 📝 `docs/CONTRIBUTING.md` (+12 -0) ➕ `i18next-parser.config.ts` (+38 -0) 📝 `package-lock.json` (+3215 -82) 📝 `package.json` (+6 -1) 📝 `src/lib/components/AddFilesPlaceholder.svelte` (+7 -2) 📝 `src/lib/components/ChangelogModal.svelte` (+7 -4) 📝 `src/lib/components/admin/EditUserModal.svelte` (+9 -7) 📝 `src/lib/components/admin/Settings/Database.svelte` (+6 -4) 📝 `src/lib/components/admin/Settings/General.svelte` (+17 -14) 📝 `src/lib/components/admin/Settings/Users.svelte` (+15 -11) 📝 `src/lib/components/admin/SettingsModal.svelte` (+7 -4) 📝 `src/lib/components/chat/MessageInput.svelte` (+23 -15) 📝 `src/lib/components/chat/MessageInput/Documents.svelte` (+8 -4) 📝 `src/lib/components/chat/MessageInput/Models.svelte` (+7 -3) 📝 `src/lib/components/chat/MessageInput/PromptCommands.svelte` (+7 -4) 📝 `src/lib/components/chat/Messages.svelte` (+4 -2) 📝 `src/lib/components/chat/Messages/Placeholder.svelte` (+5 -3) 📝 `src/lib/components/chat/Messages/ResponseMessage.svelte` (+6 -4) 📝 `src/lib/components/chat/Messages/UserMessage.svelte` (+11 -8) _...and 48 more files_ </details> ### 📄 Description ## Pull Request Checklist - [x] **Description:** Briefly describe the changes in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Have you updated relevant documentation? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? --- ## Description * This pull request introduces internationalization (i18n) to the project, including the addition of a setting input to determine the UI language. When a language is selected, the user interface adjusts accordingly. Internationalization is done using `i18next`, and could be used in svelte files like this: ```javascript // const i18n = getContext('i18n'); $i18n.t('translation key') ``` * This needs `translation key` to be present in translation files located at `src/lib/i18n/locales` for each language. Translation are specified in JSON format. Adding new `translation key`s to these translation files can be done either manually or by issuing the following command in the root directory of the project: ``` npm run i18n:parse ``` * This scans `js`/`svelte` files in the `src` directory for translation keys and adds missing keys for available languages. Available languages are specified in `src/lib/i18n/locales/languages.json`. * Also we utilize `i18next-browser-languagedetector` to detect current user's language and set it in a svelte store which will update the UI with the detected language. Detection is done in this order: 1. `querystring` (e.g `lang=en`) 2. `localStorage` 3. `navigator` * We use current string literals as translation keys, so that the keys themselves can act as fallback translation strings and also help in the process of adding translation values. --- ### Changelog Entry ### Added - Added https://github.com/i18next/i18next library dependency for i18n - Added https://github.com/i18next/i18next-browser-languageDetector, i18next plugin to detect user's language - Added https://github.com/i18next/i18next-resources-to-backend, i18next plugin to use json resource files as translation provider - Added https://github.com/i18next/i18next-parser as dev dependency to automatically insert missing keys into json translation files. - Initial setup for i18n - Added Farsi (Persian) translation - Added Deutsch (German ) translation (by @jannikstdl) - Added Ukranian translation (by @SimonOriginal ) - Added French translation (by @BYTOOX ) - Added Simplified Chinese translation (by @kawais) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 03:01:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#20534