@playstack/nest-i18n
Stateless Nest request and recipient locale resolution with explicit dependency injection.
Free. MIT licensed. Check preview availability before installing. See package access.
The Nest 10/11 binding registers a non-global locale policy and PlaystackLocaleService. It is classified Free under the Laravel localization baseline. Supply the declared Nest, RxJS and metadata peers; no database or translation provider is installed.
import { Module } from '@nestjs/common'
import { PlaystackI18nModule } from '@playstack/nest-i18n'
@Module({
imports: [
PlaystackI18nModule.forRoot({
locales: ['en', 'fr'],
source: 'en',
directions: { en: 'ltr', fr: 'ltr' },
}),
],
})
export class AppModule {}Inject PlaystackLocaleService and call resolveRequest(request, { accountLocale }) with an already-authorized account preference. It resolves Accept-Language, account preference, then source locale without mutating requests or singleton state. resolveRecipient(recipient.locale) deliberately has no HTTP context and is appropriate for delivery workers.
forRootAsync supports normal Nest imports/inject/useFactory composition. PLAYSTACK_LOCALE_POLICY and @InjectLocalePolicy() expose the underlying policy. The application owns authentication, controllers, Content-Language, Vary, cache separation and any 406 response policy. Locale is never authorization context.
The binding supports Nest 10 and 11. Registration and per-request isolation are covered by the package; how your controllers set Content-Language and cache headers remains yours to test.
Install
After confirming preview access, install the package at your application's shared Playstack version:
npm install --save-exact @playstack/nest-i18n@0.1.0-beta.1Check the peer requirements below before choosing a runtime or provider.
API entry points and requirements
Reference snapshot: @playstack/nest-i18n@0.1.0-beta.1. Import only the entry point your runtime needs. Paths below are relative to the installed package; use Go to Definition in your editor to inspect exact parameters, return types and overloads. Do not import the declaration-file paths directly.
| Public entry point | Declaration file |
|---|---|
@playstack/nest-i18n | ./dist/index.d.ts |
@playstack/nest-i18n/package.json | No TypeScript declaration (asset or metadata export). |
Node.js engine requirement: >=20. This is not a claim that every entry point works in browsers or Workers.
Peer dependencies
Keep existing framework versions that satisfy these ranges. Install optional peers only when using the corresponding adapter. The package manager resolves ordinary dependencies separately.
| Peer | Compatible range | When needed |
|---|---|---|
@playstack/i18n | 0.1.0-beta.1 | Required by the package. |
@nestjs/common | ^10.0.0 || ^11.0.0 | Required by the package. |
reflect-metadata | ^0.1.13 || ^0.2.0 | Required by the package. |
rxjs | ^7.0.0 | Required by the package. |
For a complete first program, start with Getting started. For API lookup and partial-example conventions, see Reading the reference. Provider failures, lifecycle requirements and application responsibilities remain described in the guide above; types alone do not establish production safety.