cfg72
cfg72

Reputation: 74

Translations issues, missing pipe

Im trying to add translations to spartacus. I managed to change config and have the regular translation JSON on my local, but when I try to add new translations to my HTML i always get the same issue:

"ERROR Error: The pipe 'cxTranslate' could not be found!"

This is what I have in my code:

<label for="sortDocType">Type of document: {{ 'common.back' | cxTranslate }}</label>

And my config Module:

import { ConfigModule, I18nConfig } from '@spartacus/core';
import { NgModule } from '@angular/core';
import { translationChunksConfig } from '@spartacus/assets';    
@NgModule({
      declarations: [],
      imports: [
        ConfigModule.withConfig({
          i18n: {
            backend: {
              loadPath: '../../assets/i18n-assets/{{lng}}/{{ns}}.json'
            },
            chunks: {
              ...translationChunksConfig,
            },
            fallbackLang: 'en'
          },
        } as I18nConfig)
      ],
    })

Upvotes: 2

Views: 1191

Answers (1)

Krzysztof Platis
Krzysztof Platis

Reputation: 1221

Please import I18nModule in the same module that declares your custom component:

@NgModule({
  imports: [
    I18nModule,
    /*...*/
  ],
  declarations: [
    MyComponent,
    /*...*/
  ],
  /*...*/
})
export class MyModule {}

Upvotes: 2

Related Questions