[PR #9157] feat(i18n): add built-in translations for 22 languages #25372

Open
opened 2026-04-15 22:51:26 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/9157
Author: @sovetski
Created: 4/13/2026
Status: 🔄 Open

Base: mainHead: main


📝 Commits (2)

  • 43eb8a9 feat(i18n): add built-in translations for 22 languages
  • 685bb29 Merge pull request #1 from sovetski/copilot/add-default-translations-i18n

📊 Changes

28 files changed (+1277 additions, -2 deletions)

View changed files

📝 packages/i18n/README.md (+104 -1)
📝 packages/i18n/package.json (+8 -0)
📝 packages/i18n/src/i18n.test.ts (+96 -0)
📝 packages/i18n/src/index.ts (+2 -0)
packages/i18n/src/locales/ar.ts (+43 -0)
packages/i18n/src/locales/bn.ts (+45 -0)
packages/i18n/src/locales/de.ts (+46 -0)
packages/i18n/src/locales/en.ts (+44 -0)
packages/i18n/src/locales/es.ts (+46 -0)
packages/i18n/src/locales/fa.ts (+44 -0)
packages/i18n/src/locales/fr.ts (+46 -0)
packages/i18n/src/locales/hi.ts (+45 -0)
packages/i18n/src/locales/id.ts (+45 -0)
packages/i18n/src/locales/index.ts (+76 -0)
packages/i18n/src/locales/it.ts (+46 -0)
packages/i18n/src/locales/ja.ts (+45 -0)
packages/i18n/src/locales/ko.ts (+44 -0)
packages/i18n/src/locales/nl.ts (+44 -0)
packages/i18n/src/locales/pl.ts (+47 -0)
packages/i18n/src/locales/pt.ts (+45 -0)

...and 8 more files

📄 Description

Projects using @better-auth/i18n had to define all translations themselves, there were no defaults, causing every project to duplicate the same boilerplate.

Changes

  • 22 built-in locales in packages/i18n/src/locales/: ar, bn, de, en, es, fa, fr, hi, id, it, ja, ko, nl, pl, pt, ru, sv, th, tr, uk, vi, zh — each covering all BASE_ERROR_CODES
  • New locales export from the main package entry point; tree-shakeable via a dedicated ./locales subpath export
  • Tests asserting all locales export the expected shape and work end-to-end with the plugin
  • README updated with usage examples and locale table

Usage

import { i18n, locales } from "@better-auth/i18n";

// Enable all 22 built-in locales
i18n({ translations: locales })

// Subset
i18n({ translations: { en: locales.en, fr: locales.fr } })

// Override specific messages
i18n({
  translations: {
    ...locales,
    fr: { ...locales.fr, USER_NOT_FOUND: "Membre introuvable" },
  },
})

Adding a new locale

Create src/locales/xx.ts implementing TranslationDictionary, re-export it from src/locales/index.ts. No other changes needed.


Summary by cubic

Adds 22 built-in locales to @better-auth/i18n and a tree‑shakeable locales export so apps can use defaults, pick a subset, or override messages. This removes i18n boilerplate and keeps bundles lean via a ./locales subpath.

  • New Features
    • 22 built-in locales covering all BASE_ERROR_CODES.
    • New locales export (also at @better-auth/i18n/locales) for selective import and tree-shaking.
    • Tests validating locale shape and end-to-end translations with the plugin.
    • README updated with usage examples and locale table.

Written for commit 685bb29ec3. 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/9157 **Author:** [@sovetski](https://github.com/sovetski) **Created:** 4/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`43eb8a9`](https://github.com/better-auth/better-auth/commit/43eb8a9173d462f3f1eebcbc3185c504ca638d04) feat(i18n): add built-in translations for 22 languages - [`685bb29`](https://github.com/better-auth/better-auth/commit/685bb29ec3150cc37b4efdc396209a3cda389211) Merge pull request #1 from sovetski/copilot/add-default-translations-i18n ### 📊 Changes **28 files changed** (+1277 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/i18n/README.md` (+104 -1) 📝 `packages/i18n/package.json` (+8 -0) 📝 `packages/i18n/src/i18n.test.ts` (+96 -0) 📝 `packages/i18n/src/index.ts` (+2 -0) ➕ `packages/i18n/src/locales/ar.ts` (+43 -0) ➕ `packages/i18n/src/locales/bn.ts` (+45 -0) ➕ `packages/i18n/src/locales/de.ts` (+46 -0) ➕ `packages/i18n/src/locales/en.ts` (+44 -0) ➕ `packages/i18n/src/locales/es.ts` (+46 -0) ➕ `packages/i18n/src/locales/fa.ts` (+44 -0) ➕ `packages/i18n/src/locales/fr.ts` (+46 -0) ➕ `packages/i18n/src/locales/hi.ts` (+45 -0) ➕ `packages/i18n/src/locales/id.ts` (+45 -0) ➕ `packages/i18n/src/locales/index.ts` (+76 -0) ➕ `packages/i18n/src/locales/it.ts` (+46 -0) ➕ `packages/i18n/src/locales/ja.ts` (+45 -0) ➕ `packages/i18n/src/locales/ko.ts` (+44 -0) ➕ `packages/i18n/src/locales/nl.ts` (+44 -0) ➕ `packages/i18n/src/locales/pl.ts` (+47 -0) ➕ `packages/i18n/src/locales/pt.ts` (+45 -0) _...and 8 more files_ </details> ### 📄 Description Projects using `@better-auth/i18n` had to define all translations themselves, there were no defaults, causing every project to duplicate the same boilerplate. ## Changes - **22 built-in locales** in `packages/i18n/src/locales/`: `ar`, `bn`, `de`, `en`, `es`, `fa`, `fr`, `hi`, `id`, `it`, `ja`, `ko`, `nl`, `pl`, `pt`, `ru`, `sv`, `th`, `tr`, `uk`, `vi`, `zh` — each covering all `BASE_ERROR_CODES` - **New `locales` export** from the main package entry point; tree-shakeable via a dedicated `./locales` subpath export - **Tests** asserting all locales export the expected shape and work end-to-end with the plugin - **README updated** with usage examples and locale table ## Usage ```ts import { i18n, locales } from "@better-auth/i18n"; // Enable all 22 built-in locales i18n({ translations: locales }) // Subset i18n({ translations: { en: locales.en, fr: locales.fr } }) // Override specific messages i18n({ translations: { ...locales, fr: { ...locales.fr, USER_NOT_FOUND: "Membre introuvable" }, }, }) ``` ## Adding a new locale Create `src/locales/xx.ts` implementing `TranslationDictionary`, re-export it from `src/locales/index.ts`. No other changes needed. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds 22 built-in locales to `@better-auth/i18n` and a tree‑shakeable `locales` export so apps can use defaults, pick a subset, or override messages. This removes i18n boilerplate and keeps bundles lean via a `./locales` subpath. - **New Features** - 22 built-in locales covering all `BASE_ERROR_CODES`. - New `locales` export (also at `@better-auth/i18n/locales`) for selective import and tree-shaking. - Tests validating locale shape and end-to-end translations with the plugin. - README updated with usage examples and locale table. <sup>Written for commit 685bb29ec3150cc37b4efdc396209a3cda389211. 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-04-15 22:51:26 -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#25372