Bun
2M+ weekly downloads

Bun i18n & Localization Guide

Fast i18n with Bun runtime. Use existing Node.js i18n libraries with Bun's speed. 25x faster startup. Perfect for serverless and edge deployments.

Prerequisites

  • Bun 1.x runtime installed
  • Basic JavaScript/TypeScript knowledge
  • Understanding of i18n concepts

Common Challenges

Problems developers face when localizing Bun apps—and how IntlPull helps.

Ecosystem Maturity

Newer runtime. Some edge cases with complex npm packages. Most i18n libraries work fine.

No Bun-Specific i18n

No Bun-native i18n library yet. Use Node.js libraries which work well but aren't optimized for Bun.

Documentation

i18n examples in Bun docs are limited. Rely on Node.js library docs with Bun adaptation.

Various Features

Why Various is a great choice for Bun localization.

Node.js Compatibility

Run i18next, FormatJS, and most npm i18n packages unchanged. Bun's Node.js compatibility means zero migration.

vs incompatible runtimes

Fast Startup

25x faster startup than Node.js. Ideal for serverless where cold starts matter. Load translations instantly.

vs slow Node.js startup

Built-in Bundler

Bundle translations with Bun's built-in bundler. No webpack config. Fast builds with tree-shaking.

vs complex bundler setup

Native Intl APIs

Full JavaScript Intl API support. DateTimeFormat, NumberFormat, Collator work natively.

vs polyfill requirements

TypeScript First

Native TypeScript execution. No tsc step. Type-safe translations with zero config.

vs TypeScript compilation

Edge Ready

Small runtime perfect for edge deployments. Cloudflare Workers, Vercel Edge compatibility.

vs heavy Node.js runtime

Quick Setup

Get Various running in your Bun project.

1

Create Bun Project

Initialize a new Bun project with TypeScript.

bun init -y
# or for existing project
bun add i18next
2

Install i18next

Add i18next for translation management.

bun add i18next
3

Create Translation Files

Set up locale files.

// locales/en.json
{
  "welcome": {
    "title": "Welcome to Bun",
    "description": "The fastest JavaScript runtime"
  },
  "nav": {
    "home": "Home",
    "about": "About"
  }
}

// locales/es.json
{
  "welcome": {
    "title": "Bienvenido a Bun",
    "description": "El runtime de JavaScript mas rapido"
  },
  "nav": {
    "home": "Inicio",
    "about": "Acerca"
  }
}
4

Initialize i18next

Configure i18next for Bun.

// src/i18n.ts
import i18next from 'i18next';
import en from '../locales/en.json';
import es from '../locales/es.json';

await i18next.init({
  lng: 'en',
  fallbackLng: 'en',
  resources: {
    en: { translation: en },
    es: { translation: es },
  },
  interpolation: {
    escapeValue: false,
  },
});

export default i18next;
5

Use Translations

Access translations in your Bun application.

// src/index.ts
import i18n from './i18n';

console.log(i18n.t('welcome.title')); // "Welcome to Bun"

// Change language
i18n.changeLanguage('es');
console.log(i18n.t('welcome.title')); // "Bienvenido a Bun"

// With Bun's native Intl
const formatter = new Intl.DateTimeFormat('es-ES', {
  dateStyle: 'full',
});
console.log(formatter.format(new Date())); // "lunes, 3 de febrero de 2025"

IntlPull Integration

Connect IntlPull to manage translations professionally.

1

Install IntlPull CLI

Add the CLI for translation management.

bun add -D @intlpull/cli
2

Configure intlpull.json

Set up the project configuration.

{
  "projectId": "your-project-id",
  "format": "json",
  "sourceLocale": "en",
  "localesDir": "./locales",
  "filePattern": "{locale}.json"
}
3

Pull Translations

Download translations from IntlPull.

bunx intlpull pull
4

Add to Scripts

Integrate with your workflow.

// package.json
{
  "scripts": {
    "i18n:pull": "bunx intlpull pull",
    "i18n:push": "bunx intlpull push",
    "dev": "bun run i18n:pull && bun run src/index.ts"
  }
}

Frequently Asked Questions

Ready to Localize Your Bun App?

Start with our free tier. No credit card required.

    Bun i18n & Localization Guide | IntlPull | IntlPull