locale-nestjs
Description
Locale package for NestJs
Instalation
npm i --save locale-nestjs
Quick Start
- Create a folder called 'dictionaries' on your 'src' project folder.
- On folder 'dictionaries' insert json files with translations, each file must have a name according to its locale (ex: en, pt-BR, etc..)
- Import LocaleModule and use forRoot or forRootAsync static methods on your AppModule for initial configuration (see parameters for configuration on LocaleConfig and LocaleConfigAsync files).
- Import LocaleService on your service or controller and use defineLanguage method to define current language, and translate method to return the translated message.
- Optionally you can use LocaleInterceptor on your project, this interceptor defines the current language according to 'Accept-Language' header on request.