File

projects/storefrontlib/cms-structure/services/cms-i18n.service.ts

Index

Methods

Constructor

constructor(cmsComponentsService: CmsComponentsService, translation: TranslationService, translationChunk: TranslationChunkService)
Parameters :
Name Type Optional
cmsComponentsService CmsComponentsService No
translation TranslationService No
translationChunk TranslationChunkService No

Methods

loadForComponents
loadForComponents(componentTypes: string[])
Parameters :
Name Type Optional
componentTypes string[] No
Returns : void
import { Injectable } from '@angular/core';
import { TranslationChunkService, TranslationService } from '@spartacus/core';
import { CmsComponentsService } from './cms-components.service';

@Injectable({
  providedIn: 'root',
})
export class CmsI18nService {
  constructor(
    protected cmsComponentsService: CmsComponentsService,
    protected translation: TranslationService,
    protected translationChunk: TranslationChunkService
  ) {}

  loadForComponents(componentTypes: string[]) {
    const i18nKeys = this.cmsComponentsService.getI18nKeys(componentTypes);
    const i18nChunks = new Set<string>();
    for (const key of i18nKeys) {
      i18nChunks.add(this.translationChunk.getChunkNameForKey(key));
    }
    this.translation.loadChunks(Array.from(i18nChunks));
  }
}

result-matching ""

    No results matching ""