[PR #2627] [MERGED] fix: persist user locale preference to database (#1547) #11869

Closed
opened 2026-05-06 16:28:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/pangolin/pull/2627
Author: @shreyaspapi
Created: 3/10/2026
Status: Merged
Merged: 3/30/2026
Merged by: @oschwartz10612

Base: mainHead: fix/1547-persist-user-locale


📝 Commits (2)

  • ae39084 fix: persist user locale preference to database (#1547)
  • 5455d1c fix: add locale to myDevice user query to fix type error

📊 Changes

9 files changed (+103 additions, -5 deletions)

View changed files

📝 server/db/pg/schema/schema.ts (+2 -1)
📝 server/db/sqlite/schema/schema.ts (+2 -1)
📝 server/routers/external.ts (+5 -0)
📝 server/routers/user/getUser.ts (+2 -1)
📝 server/routers/user/index.ts (+1 -0)
📝 server/routers/user/myDevice.ts (+2 -1)
server/routers/user/updateUserLocale.ts (+57 -0)
📝 src/components/LocaleSwitcherSelect.tsx (+7 -0)
📝 src/services/locale.ts (+25 -1)

📄 Description

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Fixes #1547

Language preference was only stored in a short-lived cookie, causing the dashboard to forget the selected language after about a day. This fix persists the user's locale to the database and restores it on login across devices.

Changes:

  • Added locale column to the user table (SQLite + PostgreSQL)
  • Added POST /user/locale endpoint to save locale preference
  • GET /user now returns the saved locale field
  • Locale switcher calls the API to persist on change (fire-and-forget)
  • On page load with no cookie, locale is restored from the user's DB record
  • Cookie expiry extended to 1 year as fallback

How to test?

  1. Log in and change the language via the locale switcher (profile menu)
  2. Verify the language changes immediately
  3. Clear the NEXT_LOCALE cookie from browser dev tools
  4. Refresh the page — the language should be restored from the database
  5. Open a private/incognito window, log in with the same account — the saved language should apply automatically

🔄 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/fosrl/pangolin/pull/2627 **Author:** [@shreyaspapi](https://github.com/shreyaspapi) **Created:** 3/10/2026 **Status:** ✅ Merged **Merged:** 3/30/2026 **Merged by:** [@oschwartz10612](https://github.com/oschwartz10612) **Base:** `main` ← **Head:** `fix/1547-persist-user-locale` --- ### 📝 Commits (2) - [`ae39084`](https://github.com/fosrl/pangolin/commit/ae39084a75564738efa059f40152f6725d83fc81) fix: persist user locale preference to database (#1547) - [`5455d1c`](https://github.com/fosrl/pangolin/commit/5455d1c118f65ec9e9bfc869c0e5748166085e20) fix: add locale to myDevice user query to fix type error ### 📊 Changes **9 files changed** (+103 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `server/db/pg/schema/schema.ts` (+2 -1) 📝 `server/db/sqlite/schema/schema.ts` (+2 -1) 📝 `server/routers/external.ts` (+5 -0) 📝 `server/routers/user/getUser.ts` (+2 -1) 📝 `server/routers/user/index.ts` (+1 -0) 📝 `server/routers/user/myDevice.ts` (+2 -1) ➕ `server/routers/user/updateUserLocale.ts` (+57 -0) 📝 `src/components/LocaleSwitcherSelect.tsx` (+7 -0) 📝 `src/services/locale.ts` (+25 -1) </details> ### 📄 Description ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## Description Fixes #1547 Language preference was only stored in a short-lived cookie, causing the dashboard to forget the selected language after about a day. This fix persists the user's locale to the database and restores it on login across devices. **Changes:** - Added `locale` column to the user table (SQLite + PostgreSQL) - Added `POST /user/locale` endpoint to save locale preference - `GET /user` now returns the saved `locale` field - Locale switcher calls the API to persist on change (fire-and-forget) - On page load with no cookie, locale is restored from the user's DB record - Cookie expiry extended to 1 year as fallback ## How to test? 1. Log in and change the language via the locale switcher (profile menu) 2. Verify the language changes immediately 3. Clear the `NEXT_LOCALE` cookie from browser dev tools 4. Refresh the page — the language should be restored from the database 5. Open a private/incognito window, log in with the same account — the saved language should apply automatically --- <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-05-06 16:28:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/pangolin#11869