Skip to content
/ i18n Public

Angular - i18n module based on ngx-translate

Notifications You must be signed in to change notification settings

ng-sm/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6a3580a · Jun 5, 2021

History

11 Commits
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
Jun 5, 2021

Repository files navigation

I18n module based on the @ngx-translate/core package.

Installation

yarn add @ngsm/i18n or npm i @ngsm/i18n --save

Usage

App module:

import { I18nModule } from '@ngsm/i18n';
...

@NgModule({
  imports: [
    ...
    // Option 1: module without paramaters 
    I18nModule,
    // Option 2: module with parameters
    // Add new langs to the list. Default language should be added as a first.
    I18nModule.forRoot({ 
      languages: ['en', 'pl']
    }),
  ],
  ...
})
export class AppModule {}

Translations should be added in i18n directory in your assets (for example /src/assets/i18n/en.json):

{
  "homepage": {
    "title": "My title"
  }
}

In your HTML:

{{ 'homepage.title' | translate }}

Author

Sebastian Musiał

[email protected]

@sebamusial