Registry /
web-framework / ngx-translate-formatjs-compiler
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TranslateFormatJsCompiler
✓ import { TranslateFormatJsCompiler } from 'ngx-translate-formatjs-compiler';
✗ const TranslateFormatJsCompiler = require('ngx-translate-formatjs-compiler');
ES module import; requires Angular >=10 and @ngx-translate/core >=13.
TranslateModule
✓ import { TranslateModule, TranslateCompiler } from '@ngx-translate/core';
✗ import { TranslateModule } from 'ngx-translate-formatjs-compiler';
TranslateModule and TranslateCompiler are from @ngx-translate/core, not this package.
TranslateCompiler
✓ import { TranslateCompiler } from '@ngx-translate/core';
✗ import { TranslateCompiler } from 'ngx-translate-formatjs-compiler';
TranslateCompiler is a provider token from @ngx-translate/core.
Setup of TranslateFormatJsCompiler in Angular app module and example ICU message translation.
// app.module.ts
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';
@NgModule({
imports: [
BrowserModule,
TranslateModule.forRoot({
compiler: {
provide: TranslateCompiler,
useClass: TranslateFormatJsCompiler
}
})
],
bootstrap: [AppComponent]
})
export class AppModule {}
// translation file example (en.json):
{
"welcome": "Hello, {name}! You have {count, plural, one {# message} other {# messages}}."
}
Errors
Common errors & fixes
ERROR in node_modules/ngx-translate-formatjs-compiler/lib/translate-formatjs-compiler.d.ts:1:63 - error TS2307: Cannot find module 'intl-messageformat'.
Missing intl-messageformat peer dependency
fixnpm install intl-messageformat
NullInjectorError: No provider for TranslateCompiler!
TranslateFormatJsCompiler not provided in NgModule's compiler
fixEnsure you configure TranslateModule.forRoot with compiler: { provide: TranslateCompiler, useClass: TranslateFormatJsCompiler } Error: SyntaxError: Expected a double-quoted property name in JSON at position ...
Translation file not in valid JSON format or ICU syntax error
fixValidate your translation JSON files; ensure ICU expressions are correctly formed.
Audit
Dependencies
intl-messageformatrequiredpeer dependency for ICU message formatting
@ngx-translate/corerequiredpeer dependency - core translation module
@angular/corerequiredpeer dependency - Angular core
@angular/commonrequiredpeer dependency - Angular common