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'.
Open your browser settings and change the preferred language to something like French.
Make sure the NEXT_LOCALE cookie is not set by clearing cookies or using an incognito/private window.
Visit the app in a new tab or incognito window.
Set your browser to a language not included in the app’s locales. The application should fallback to en-US.
Cookie Override Test: If NEXT_LOCALE cookie is set (e.g., via language switcher), it should take priority over browser settings on the next visit.
🔄 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/1205
**Author:** [@Pallavikumarimdb](https://github.com/Pallavikumarimdb)
**Created:** 8/3/2025
**Status:** ✅ Merged
**Merged:** 8/3/2025
**Merged by:** [@oschwartz10612](https://github.com/oschwartz10612)
**Base:** `dev` ← **Head:** `feature-default-language`
---
### 📝 Commits (2)
- [`3fbfe50`](https://github.com/fosrl/pangolin/commit/3fbfe50e09e23fd9a7ce86f03cfc726751aad559) Default language detection via browser language header
- [`616dae2`](https://github.com/fosrl/pangolin/commit/616dae2d8b0a06f299154f1f82d604378b69653d) code format
### 📊 Changes
**1 file changed** (+24 additions, -4 deletions)
<details>
<summary>View changed files</summary>
📝 `src/services/locale.ts` (+24 -4)
</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
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:
1. If a cookie exists and its value matches one of the app-supported locales (/i18n/config.ts), it is used.
2. 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.
3. If no match is found, the app falls back to the default locale: 'en-US'.
Fixes #1131
## How to test?
1. Open your browser settings and change the preferred language to something like French.
2. Make sure the NEXT_LOCALE cookie is not set by clearing cookies or using an incognito/private window.
3. Visit the app in a new tab or incognito window.
5. Set your browser to a language not included in the app’s locales. The application should fallback to en-US.
6. Cookie Override Test: If NEXT_LOCALE cookie is set (e.g., via language switcher), it should take priority over browser settings on the next visit.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 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.