[PR #6226] [MERGED] feat(i18n): translate the log levels, access events and calendar labels #6188

Closed
opened 2026-11-02 04:06:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6226
Author: @n0ctal
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @MHSanaei

Base: main ← Head: upstream-i18n-hardcoded-strings


📝 Commits (2)

  • b9ca4c8 feat(i18n): translate the log levels, access events and calendar labels
  • 083f703 fix(i18n): keep the log export language-independent and fit the translations

📊 Changes

19 files changed (+234 additions, -66 deletions)

View changed files

📝 frontend/public/mockServiceWorker.js (+21 -9)
📝 frontend/src/layouts/AppSidebar.tsx (+1 -1)
📝 frontend/src/pages/index/IndexPage.tsx (+1 -1)
📝 frontend/src/pages/index/LogModal.tsx (+6 -6)
📝 frontend/src/pages/index/XrayLogModal.tsx (+19 -5)
📝 frontend/src/pages/settings/GeneralTab.tsx (+4 -5)
📝 internal/web/translation/ar-EG.json (+14 -3)
📝 internal/web/translation/en-US.json (+14 -3)
📝 internal/web/translation/es-ES.json (+14 -3)
📝 internal/web/translation/fa-IR.json (+14 -3)
📝 internal/web/translation/id-ID.json (+14 -3)
📝 internal/web/translation/ja-JP.json (+14 -3)
📝 internal/web/translation/pt-BR.json (+14 -3)
📝 internal/web/translation/ru-RU.json (+14 -3)
📝 internal/web/translation/tr-TR.json (+14 -3)
📝 internal/web/translation/uk-UA.json (+14 -3)
📝 internal/web/translation/vi-VN.json (+14 -3)
📝 internal/web/translation/zh-CN.json (+14 -3)
📝 internal/web/translation/zh-TW.json (+14 -3)

📄 Description

Closes part of #5820.

Summary

The log-level selector, the access-log event tags, the Sub Formats sidebar entry and the calendar choices were hardcoded English. A user on a fully translated locale still met English on the dashboard, the log modals and the settings page.

Eleven keys added across all 13 locales and wired up.

Why the list is shorter than the issue's

The issue lists roughly thirty strings. I went through them against current main rather than by line number, and most should stay as they are:

  • Proper nouns — V2RayNG, Sing-box, Shadowrocket, Happ, Incy, V2Box. Product names are not translated in any locale.
  • Protocol and format acronyms — SNI, uTLS, ALPN, TCP, UDP, IPv4, IPv6, DNS, JSON, CLASH, ID. These are identical in every language the panel ships; a key per acronym adds 13 lines each and buys nothing.
  • Not user-visible — clients-export.json and config.json are filenames, not labels.
  • Already fixed — several dashboard entries the issue points at (Xray, OS, Copy) no longer exist at those lines.

What was left is the genuinely translatable remainder:

what keys
log levels: Debug, Info, Notice, Warning, Error pages.index.logLevel*
access-log events: DIRECT, BLOCKED, PROXY pages.index.access*
sidebar entry: Sub Formats menu.subFormats
calendar choices: Gregorian, Jalalian pages.settings.calendar*

'Copied' on the dashboard now uses the existing copied key instead of a new one.

Translations

English, Russian and Ukrainian are translated. The other ten locales carry the English string — the same convention those files already use, where between 4% and 9% of entries are currently untranslated English. I would rather leave a correct English fallback than guess at Farsi or Vietnamese; a native speaker can fill them in later without touching code.

Two structural changes

Both were forced, not stylistic. The calendar list and the access-event map were module-level constants, and t only exists inside the component:

  • DATEPICKER_LIST is gone; the two options are built inline where t is in scope.
  • EVENT_LABELS became EVENT_KEYS and eventLabel takes t, resolving the key at render so it follows a language switch instead of freezing at import.

Validation

i18n-dead-keys passes — it caught the three access keys while they were added but not yet referenced, which is exactly what it is for. tsc --noEmit clean, eslint src clean, and the unit suite is green (55 files, 936 tests).


🔄 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/MHSanaei/3x-ui/pull/6226 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/18/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `upstream-i18n-hardcoded-strings` --- ### 📝 Commits (2) - [`b9ca4c8`](https://github.com/MHSanaei/3x-ui/commit/b9ca4c88097971e5fc467f349852a41f3d7b0c56) feat(i18n): translate the log levels, access events and calendar labels - [`083f703`](https://github.com/MHSanaei/3x-ui/commit/083f7033684d25951cfe51ad6e385ffea0ff02d2) fix(i18n): keep the log export language-independent and fit the translations ### 📊 Changes **19 files changed** (+234 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/mockServiceWorker.js` (+21 -9) 📝 `frontend/src/layouts/AppSidebar.tsx` (+1 -1) 📝 `frontend/src/pages/index/IndexPage.tsx` (+1 -1) 📝 `frontend/src/pages/index/LogModal.tsx` (+6 -6) 📝 `frontend/src/pages/index/XrayLogModal.tsx` (+19 -5) 📝 `frontend/src/pages/settings/GeneralTab.tsx` (+4 -5) 📝 `internal/web/translation/ar-EG.json` (+14 -3) 📝 `internal/web/translation/en-US.json` (+14 -3) 📝 `internal/web/translation/es-ES.json` (+14 -3) 📝 `internal/web/translation/fa-IR.json` (+14 -3) 📝 `internal/web/translation/id-ID.json` (+14 -3) 📝 `internal/web/translation/ja-JP.json` (+14 -3) 📝 `internal/web/translation/pt-BR.json` (+14 -3) 📝 `internal/web/translation/ru-RU.json` (+14 -3) 📝 `internal/web/translation/tr-TR.json` (+14 -3) 📝 `internal/web/translation/uk-UA.json` (+14 -3) 📝 `internal/web/translation/vi-VN.json` (+14 -3) 📝 `internal/web/translation/zh-CN.json` (+14 -3) 📝 `internal/web/translation/zh-TW.json` (+14 -3) </details> ### 📄 Description Closes part of #5820. ## Summary The log-level selector, the access-log event tags, the `Sub Formats` sidebar entry and the calendar choices were hardcoded English. A user on a fully translated locale still met English on the dashboard, the log modals and the settings page. Eleven keys added across all 13 locales and wired up. ## Why the list is shorter than the issue's The issue lists roughly thirty strings. I went through them against current `main` rather than by line number, and most should stay as they are: - **Proper nouns** — `V2RayNG`, `Sing-box`, `Shadowrocket`, `Happ`, `Incy`, `V2Box`. Product names are not translated in any locale. - **Protocol and format acronyms** — `SNI`, `uTLS`, `ALPN`, `TCP`, `UDP`, `IPv4`, `IPv6`, `DNS`, `JSON`, `CLASH`, `ID`. These are identical in every language the panel ships; a key per acronym adds 13 lines each and buys nothing. - **Not user-visible** — `clients-export.json` and `config.json` are filenames, not labels. - **Already fixed** — several dashboard entries the issue points at (`Xray`, `OS`, `Copy`) no longer exist at those lines. What was left is the genuinely translatable remainder: | what | keys | |---|---| | log levels: Debug, Info, Notice, Warning, Error | `pages.index.logLevel*` | | access-log events: DIRECT, BLOCKED, PROXY | `pages.index.access*` | | sidebar entry: Sub Formats | `menu.subFormats` | | calendar choices: Gregorian, Jalalian | `pages.settings.calendar*` | `'Copied'` on the dashboard now uses the existing `copied` key instead of a new one. ## Translations English, Russian and Ukrainian are translated. The other ten locales carry the English string — the same convention those files already use, where between 4% and 9% of entries are currently untranslated English. I would rather leave a correct English fallback than guess at Farsi or Vietnamese; a native speaker can fill them in later without touching code. ## Two structural changes Both were forced, not stylistic. The calendar list and the access-event map were module-level constants, and `t` only exists inside the component: - `DATEPICKER_LIST` is gone; the two options are built inline where `t` is in scope. - `EVENT_LABELS` became `EVENT_KEYS` and `eventLabel` takes `t`, resolving the key at render so it follows a language switch instead of freezing at import. ## Validation `i18n-dead-keys` passes — it caught the three access keys while they were added but not yet referenced, which is exactly what it is for. `tsc --noEmit` clean, `eslint src` clean, and the unit suite is green (55 files, 936 tests). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:59 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6188
No description provided.