All files / src/lib/i18n FakeLoader.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                  11x     11x             11x   20x      
/**
 * @module module:lib/i18n/FakeLoader
 * @description Simple fake translate loader used for tests or fallback scenarios.
 * @summary Implements a minimal TranslateLoader that returns a small set of default
 * translation keys. Useful for development, demos or when a full HTTP-backed loader is not available.
 *
 * @link {@link I18nFakeLoader}
 */
import { TranslateLoader } from "@ngx-translate/core";
import { Observable, of } from "rxjs";
import { KeyValue } from "../engine";
 
export const MockedEnTranslations = {
  FIELD_LABEL: 'Translated Label',
  FIELD_PLACEHOLDER: 'Translated Placeholder',
  HELLO: 'Hello',
  GOODBYE: 'Goodbye'
} as const;
 
export class I18nFakeLoader implements TranslateLoader {
  getTranslation(): Observable<KeyValue> {
    return of(MockedEnTranslations);
  }
}