📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

ngx-translate-formatjs-compiler

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-translate-formatjs-compiler

[Format.js](https://formatjs.io/) based [@ngx/translate](https://github.com/ngx-translate/core) compiler.

1.0.8
latest
Version published
Weekly downloads
458
34.31%
Maintainers
1
Weekly downloads
 
Created

ngx-translate-formatjs-compiler Node.js CI npm version CodeQL

Format.js based @ngx/translate compiler.

Supports Angular >= 10

Install

npm i --save intl-messageformat @ngx-translate/core ngx-translate-formatjs-compiler

Integration in @ngx/translate/core

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { TranslateCompiler, TranslateModule } from '@ngx-translate/core';
import { TranslateFormatJsCompiler } from 'ngx-translate-formatjs-compiler';

import { AppComponent } from './app';

@NgModule({
  imports: [
    BrowserModule,
    TranslateModule.forRoot({
      compiler: {
        provide: TranslateCompiler,
        useClass: TranslateFormatJsCompiler,
      },
    }),
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

Troubleshooting

  • With FormatJS HTML tags must be escaped with a ' in the translation. E.g. '<h1>'Your content goes here'</h1>'
  • With FormatJS interpolation variables are surrounded by single brackets. E.g. I am having {count} cats

FAQs

Package last updated on 28 Jul 2022

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