项目作者: ng-sm

项目描述 :
Angular - i18n module based on ngx-translate
高级语言: TypeScript
项目地址: git://github.com/ng-sm/i18n.git
创建时间: 2020-05-03T12:30:00Z
项目社区:https://github.com/ng-sm/i18n

开源协议:

下载








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

Installation

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

Usage

App module:

  1. import { I18nModule } from '@ngsm/i18n';
  2. ...
  3. @NgModule({
  4. imports: [
  5. ...
  6. // Option 1: module without paramaters
  7. I18nModule,
  8. // Option 2: module with parameters
  9. // Add new langs to the list. Default language should be added as a first.
  10. I18nModule.forRoot({
  11. languages: ['en', 'pl']
  12. }),
  13. ],
  14. ...
  15. })
  16. export class AppModule {}

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

  1. {
  2. "homepage": {
  3. "title": "My title"
  4. }
  5. }

In your HTML:

  1. {{ 'homepage.title' | translate }}

Author











Sebastian Musiał


kontakt@sebastianmusial.pl


@sebamusial