Internationalization with i18next, language detection, and React provider support.
- 🪧 About
- 📦 Installation
- 🚀 Usage
- 📖 API
- 🤗 Contributing
- 📝 License
Framework-agnostic i18n library built on i18next with pluggable language detectors, resource loaders, and React provider support. Includes a Next.js subpath for server-side language detection and metadata translation.
pnpm add @arckit/i18nimport { detectLng } from '@arckit/i18n';
import { fromCookie, fromHeader } from '@arckit/i18n/detectors';
const lng = await detectLng(request, {
detectors: [fromCookie({ cookieName: 'locale', supportedLngs }), fromHeader({ supportedLngs })],
fallbackLng: 'en-US'
});import { I18nProvider } from '@arckit/i18n/client';
<I18nProvider locale={locale} namespaces={namespaces} resources={resources}>
{children}
</I18nProvider>| Export | Description |
|---|---|
detectLng(request, options) |
Detect language from request using pluggable detectors |
RESOURCE_LOADER |
Injection key for the resource loader function |
TRANSLATION |
Injection key for the translation function |
withTranslation(Component) |
HOC that injects the t function as prop |
| Export | Description |
|---|---|
I18nProvider |
React provider for client-side i18n context |
| Export | Description |
|---|---|
fromCookie(options) |
Detect language from a cookie |
fromHeader(options) |
Detect language from Accept-Language header |
fromUrl(options) |
Detect language from URL path |
See CONTRIBUTING.md for details.
MIT © Marc Gavanier