[PR #6788] [CLOSED] feat: add i18n plugin #15130

Closed
opened 2026-04-13 09:50:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6788
Author: @himself65
Created: 12/16/2025
Status: Closed

Base: canaryHead: himself65/2025/12/16/i18n


📝 Commits (1)

📊 Changes

4 files changed (+77 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/client/config.ts (+2 -1)
📝 packages/better-auth/src/client/fetch-plugins.ts (+39 -0)
packages/better-auth/src/client/translation.test.ts (+33 -0)
📝 packages/core/src/types/plugin-client.ts (+3 -0)

📄 Description

Summary by cubic

Add a client-side i18n plugin that translates API error codes into localized messages, configurable via a translations map. Improves user-facing error text without server changes.

  • New Features
    • Introduced translationClientPlugin that intercepts non-OK responses and maps error code -> localized message (updates data.message, data.error.message, and statusText).
    • getClientConfig registers the plugin; it activates only if translations are provided.
    • Added translations option to BetterAuthClientOptions (typed against BASE_ERROR_CODES with support for custom codes).
    • Added unit test covering code-to-message translation (e.g., USER_NOT_FOUND -> 用户找不到).

Written for commit e721907ecf. Summary will update automatically 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/6788 **Author:** [@himself65](https://github.com/himself65) **Created:** 12/16/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/12/16/i18n` --- ### 📝 Commits (1) - [`e721907`](https://github.com/better-auth/better-auth/commit/e721907ecfe2b06510d716bb520a540c35074e4c) feat: add i18n plugin ### 📊 Changes **4 files changed** (+77 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/config.ts` (+2 -1) 📝 `packages/better-auth/src/client/fetch-plugins.ts` (+39 -0) ➕ `packages/better-auth/src/client/translation.test.ts` (+33 -0) 📝 `packages/core/src/types/plugin-client.ts` (+3 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add a client-side i18n plugin that translates API error codes into localized messages, configurable via a translations map. Improves user-facing error text without server changes. - New Features - Introduced translationClientPlugin that intercepts non-OK responses and maps error code -> localized message (updates data.message, data.error.message, and statusText). - getClientConfig registers the plugin; it activates only if translations are provided. - Added translations option to BetterAuthClientOptions (typed against BASE_ERROR_CODES with support for custom codes). - Added unit test covering code-to-message translation (e.g., USER_NOT_FOUND -> 用户找不到). <sup>Written for commit e721907ecfe2b06510d716bb520a540c35074e4c. Summary will update automatically 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-04-13 09:50:48 -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#15130