Skip to content

feat: add auto locale switch on first visit based on browser language#160

Open
lingxh wants to merge 1 commit intobulwarkmail:mainfrom
lingxh:auto-lang
Open

feat: add auto locale switch on first visit based on browser language#160
lingxh wants to merge 1 commit intobulwarkmail:mainfrom
lingxh:auto-lang

Conversation

@lingxh
Copy link
Copy Markdown
Contributor

@lingxh lingxh commented Apr 6, 2026

Summary

This PR adds a feature to automatically switch the site language to the user's browser language on their first visit. The behavior is controlled by the NEXT_PUBLIC_AUTO_SWITCH_LOCALE_ON_FIRST_VISIT environment variable and is disabled by default.

Changes

  • Add automatic locale detection on first visit using the browser language
  • Only trigger the auto-switch on the user's first visit
  • Add NEXT_PUBLIC_AUTO_SWITCH_LOCALE_ON_FIRST_VISIT environment variable to control the feature
  • Default behavior keeps the feature disabled unless explicitly enabled
  • Ensure existing locale preference is not overridden after the first visit

Related Issues

Closes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactor / code quality improvement
  • Chore / dependency update / CI change

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style and conventions
  • I have run npm run typecheck && npm run lint and there are no errors
  • The build passes (npm run build)
  • I have tested my changes locally
  • I have added or updated documentation if needed
  • I have updated translations (locales/) if my changes affect user-facing text
  • I have included screenshots or a screen recording for UI changes

Screenshots / Demo

N/A

Notes for Reviewers

  • The feature is guarded by the NEXT_PUBLIC_AUTO_SWITCH_LOCALE_ON_FIRST_VISIT environment variable.
  • Default value is disabled, so there is no behavior change unless the variable is enabled.
  • The auto-switch only happens on the first visit to avoid overriding user-selected language preferences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant