[PR #7834] [MERGED] fix(i18n): allow getLocale callback when request is undefined #7581

Closed
opened 2026-03-13 13:42:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7834
Author: @bytaesu
Created: 2/7/2026
Status: Merged
Merged: 2/7/2026
Merged by: @himself65

Base: canaryHead: 2026-02-07/fix/i18n-callback-optional-request


📝 Commits (4)

  • 81e42a9 fix(i18n): allow getLocale callback when request is undefined
  • c0b3038 Merge branch 'canary' into 2026-02-07/fix/i18n-callback-optional-request
  • e3c1288 fix: misc
  • 90f7c9c chore: clearer docs

📊 Changes

4 files changed (+43 additions, -7 deletions)

View changed files

📝 docs/content/docs/plugins/i18n.mdx (+6 -1)
📝 packages/i18n/src/i18n.test.ts (+33 -3)
📝 packages/i18n/src/index.ts (+1 -1)
📝 packages/i18n/src/types.ts (+3 -2)

📄 Description

Note

The callback type changes, but this plugin currently exists in beta. Also, other callbacks usually use Request | undefined.


Summary by cubic

Allow getLocale to run when request is undefined to fix locale detection in non-HTTP flows (e.g., auth.api).

  • Bug Fixes
    • Always call getLocale for the "callback" strategy, even without a request; closes #7805.
    • Update types to (Request | undefined, AuthContext); docs add a note that request can be undefined and show an early-return example; tests cover header detection and the auth.api no-request flow.

Written for commit 90f7c9c887. Summary will update on new commits.


🔄 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/better-auth/better-auth/pull/7834 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/7/2026 **Status:** ✅ Merged **Merged:** 2/7/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-02-07/fix/i18n-callback-optional-request` --- ### 📝 Commits (4) - [`81e42a9`](https://github.com/better-auth/better-auth/commit/81e42a986c84a6530bb79aa08470200a649c0872) fix(i18n): allow getLocale callback when request is undefined - [`c0b3038`](https://github.com/better-auth/better-auth/commit/c0b3038f32ad9338fbd15e48ef5bab96e546fa5d) Merge branch 'canary' into 2026-02-07/fix/i18n-callback-optional-request - [`e3c1288`](https://github.com/better-auth/better-auth/commit/e3c1288a7fe9114ddbce8bc36b8bba25749b73ba) fix: misc - [`90f7c9c`](https://github.com/better-auth/better-auth/commit/90f7c9c887dad35e0c058d238c2f51b0acd15f56) chore: clearer docs ### 📊 Changes **4 files changed** (+43 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/i18n.mdx` (+6 -1) 📝 `packages/i18n/src/i18n.test.ts` (+33 -3) 📝 `packages/i18n/src/index.ts` (+1 -1) 📝 `packages/i18n/src/types.ts` (+3 -2) </details> ### 📄 Description > [!NOTE] > The callback type changes, but this plugin currently exists in beta. Also, other callbacks usually use `Request | undefined`. - Closes https://github.com/better-auth/better-auth/issues/7805 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allow getLocale to run when request is undefined to fix locale detection in non-HTTP flows (e.g., auth.api). - **Bug Fixes** - Always call getLocale for the "callback" strategy, even without a request; closes #7805. - Update types to (Request | undefined, AuthContext); docs add a note that request can be undefined and show an early-return example; tests cover header detection and the auth.api no-request flow. <sup>Written for commit 90f7c9c887dad35e0c058d238c2f51b0acd15f56. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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-03-13 13:42:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7581