fix: persist user locale preference to database (#1547) #135

Closed
opened 2026-04-05 17:01:22 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @shreyaspapi on 3/10/2026

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
*Originally created by @shreyaspapi on 3/10/2026* ## 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
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/pangolin#135