[PR #4890] [MERGED] fix(i18n): add 1-year expiration to language cookie #5742

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4890
Author: @lim-kim930
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @MHSanaei

Base: main ← Head: main


📝 Commits (1)

  • 4c6cf9b fix(i18n): add 1-year expiration to language cookie

📊 Changes

1 file changed (+4 additions, -4 deletions)

View changed files

📝 frontend/src/utils/index.ts (+4 -4)

📄 Description

Summary

Added a 1-year expiration time to the lang cookie in the frontend to make it a persistent cookie instead of a session cookie.

Why

Previously, the lang cookie was set without an expiration date, which made it a Session Cookie. This caused users to lose their UI language preference every time they closed and reopened their browser. Additionally, because the backend relies on this cookie to determine the localized language for prompts and errors (web/locale/locale.go), the backend would also fall back to English/browser defaults upon browser restart.
Adding a 1-year expiration ensures the user's language setting persists properly and improves the overall user experience.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  1. Open the panel UI in the browser and change the language from the default (e.g., to zh-CN).
  2. Verify in the browser's DevTools (Application -> Cookies) that the lang cookie now has an Expires/Max-Age set to 1 year in the future, rather than Session.
  3. Completely close the browser (all tabs/windows).
  4. Reopen the browser and visit the panel UI again.
  5. Confirmed that the previously selected language is preserved correctly instead of reverting to the default.

Screenshots / recordings

N/A

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/4890 **Author:** [@lim-kim930](https://github.com/lim-kim930) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`4c6cf9b`](https://github.com/MHSanaei/3x-ui/commit/4c6cf9bc4b7fd6294d30f85f932ad1897b1c06ba) fix(i18n): add 1-year expiration to language cookie ### 📊 Changes **1 file changed** (+4 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/utils/index.ts` (+4 -4) </details> ### 📄 Description ## Summary Added a 1-year expiration time to the `lang` cookie in the frontend to make it a persistent cookie instead of a session cookie. ## Why Previously, the `lang` cookie was set without an expiration date, which made it a Session Cookie. This caused users to lose their UI language preference every time they closed and reopened their browser. Additionally, because the backend relies on this cookie to determine the localized language for prompts and errors (`web/locale/locale.go`), the backend would also fall back to English/browser defaults upon browser restart. Adding a 1-year expiration ensures the user's language setting persists properly and improves the overall user experience. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? 1. Open the panel UI in the browser and change the language from the default (e.g., to `zh-CN`). 2. Verify in the browser's DevTools (Application -> Cookies) that the `lang` cookie now has an `Expires/Max-Age` set to 1 year in the future, rather than `Session`. 3. Completely close the browser (all tabs/windows). 4. Reopen the browser and visit the panel UI again. 5. Confirmed that the previously selected language is preserved correctly instead of reverting to the default. ## Screenshots / recordings N/A ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:03:45 +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#5742
No description provided.