mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-16 14:47:04 -05:00
[PR #1205] [MERGED] System wide default language detection via browser language header #26018
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/pangolin/pull/1205
Author: @Pallavikumarimdb
Created: 8/3/2025
Status: ✅ Merged
Merged: 8/3/2025
Merged by: @oschwartz10612
Base:
dev← Head:feature-default-language📝 Commits (2)
3fbfe50Default language detection via browser language header616dae2code format📊 Changes
1 file changed (+24 additions, -4 deletions)
View changed files
📝
src/services/locale.ts(+24 -4)📄 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
This PR adds support for detecting a user's preferred language from their browser settings (Accept-Language header) and falling back to a predefined default (en-US) when not available. The flow works as follows:
If a cookie exists and its value matches one of the app-supported locales (/i18n/config.ts), it is used.
If not, the Accept-Language header from the browser is parsed.
We extract the base language (e.g., fr from fr-FR).
We try to match it against available locales by comparing prefixes.
If no match is found, the app falls back to the default locale: 'en-US'.
Fixes #1131
How to test?
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.