Skip to content

@galaxy-stack/orbit-i18n

Internationalization — nested translations, {param} interpolation, fallback locales, request locale resolution.

bash
bun add @galaxy-stack/orbit-i18n

Usage

ts
import { I18nModule, I18nService, Module } from '@galaxy-stack/orbit-i18n';

@Module({
  imports: [I18nModule.forRoot({
    translations: {
      en: { greeting: 'Hello {name}!' },
      vi: { greeting: 'Xin chào {name}!' },
    },
    defaultLocale: 'en',
    fallbackLocale: 'en',
  })],
})
export class AppModule {}

// anywhere with DI:
constructor(private i18n: I18nService) {}
greet(name: string, locale: string) { return this.i18n.t('greeting', { name }, locale); }

resolveLocale(request) reads ?langx-localeaccept-language → default.

Released under the MIT License.