10.0.0 • Published 7 months ago

nestjs-translate v10.0.0

Weekly downloads
141
License
MIT
Repository
-
Last release
7 months ago

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');
    }
}
10.0.0

7 months ago

9.0.0

1 year ago

8.0.0-beta.15

2 years ago

8.0.0-beta.14

3 years ago

7.0.0-beta.13

4 years ago

1.0.0-beta.12

5 years ago

1.0.0-beta.11

5 years ago

1.0.0-beta.10

5 years ago

1.0.0-beta.9

5 years ago

1.0.0-beta.8

5 years ago

1.0.0-beta.7

5 years ago

1.0.0-beta.6

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.4

5 years ago

1.0.0-beta.3

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-beta.0

5 years ago

1.0.0-beta

6 years ago