$ show nivandres/intl-t
The intl-t repository is a fully-typed, object-based internationalization (i18n) library for TypeScript, React, and Next.js applications. It provides a translation engine that allows developers to access nested translation objects via property traversal (e.g., `t.page.section.title`) with full TypeScript safety. The library supports ICU message formatting for plurals, selections, and variable injection, including the ability to embed React components within translated strings. Architecturally, the library is structured as a monorepo with separate packages for core logic, framework integrations (React and Next.js), utilities, formatting, type declaration generation, and locale definitions. The core package is framework-agnostic and uses proxies to enable lazy loading of locale-specific translation trees for code splitting. Framework-specific packages provide hooks, context providers, middleware, and routing helpers tailored to React and Next.js, including Next.js App Router support for server components and static rendering. The library emphasizes zero external dependencies, modern JavaScript features, and type safety. It includes a CLI tool for generating TypeScript definitions from JSON translation files, ensuring that translation keys are fully typed and IDE-friendly. The Next.js integration offers automatic locale detection, URL localization, and caching mechanisms optimized for server-side rendering and edge environments.
The LLM identified 4 files worth highlighting for reuse:
Implements ICU message formatting for plurals, select, number/date/time, and custom formats. Self-contained, framework-agnostic, and reusable in any JavaScript/TypeScript project needing ICU formatting.
Enables embedding React components within translation strings, allowing dynamic content like links or formatted text to be part of localized content. Isolated to React and demonstrates a non-obvious pattern for flexible i18n in UI libraries.
Next.js middleware that automatically detects user locale via headers, cookies, or URL path and rewrites requests to serve localized content. Supports multiple routing strategies (path prefix, domain, etc.) and is configurable for diverse internationalization needs.
Standalone locale negotiation algorithm that determines the best matching locale from a set of available locales based on user preferences. Zero dependencies, highly reusable in any JavaScript environment requiring locale matching.