Socket
Book a DemoInstallSign in
Socket

nestjs-translate

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-translate

Translate library for NestJs

10.0.0
latest
npmnpm
Version published
Weekly downloads
83
-33.6%
Maintainers
2
Weekly downloads
 
Created
Source

nestjs-translation

A i18n library for NestJs.

This library is work in progress

Installation

npm install nestjs-translate --save

This library works only with Nest5

Usage

1. Import TranslateModule

The first step is to import the adding TranslateModule.forRoot in your AppModule. The forRoot function takes the path of the i18n files to load.

@Module({
    imports: [
       TranslateModule.forRoot(__dirname + '/../assets/i18n')
    ]
})
export class ApplicationModule {
}

2. Use the TranslateService

For the moment, the default language is set to en. You can overwrite the language when getting a translation.

@Injectable()
export class HomeService {
    constructor(private translateService: TranslateService){}
    
    public defaultWelcomeMessage(lang: string) {
        return this.translateService.get('welcome');
    }
    
    public welcomeMessage(lang: string) {
        return this.translateService.get(lang, 'welcome');
    }
}

FAQs

Package last updated on 06 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.