@ngx-translate/core

  • Version 14.0.0
  • Published
  • 384 kB
  • 1 dependency
  • MIT license

Install

npm i @ngx-translate/core
yarn add @ngx-translate/core
pnpm add @ngx-translate/core

Overview

The internationalization (i18n) library for Angular

Index

Variables

Classes

Interfaces

Variables

variable DEFAULT_LANGUAGE

const DEFAULT_LANGUAGE: InjectionToken<string>;

    variable USE_DEFAULT_LANG

    const USE_DEFAULT_LANG: InjectionToken<string>;

      variable USE_EXTEND

      const USE_EXTEND: InjectionToken<string>;

        variable USE_STORE

        const USE_STORE: InjectionToken<string>;

          Classes

          class FakeMissingTranslationHandler

          class FakeMissingTranslationHandler implements MissingTranslationHandler {}
          • This handler is just a placeholder that does nothing, in case you don't need a missing translation handler at all

          property ɵfac

          static ɵfac: i0.ɵɵFactoryDeclaration<FakeMissingTranslationHandler, never>;

            property ɵprov

            static ɵprov: i0.ɵɵInjectableDeclaration<FakeMissingTranslationHandler>;

              method handle

              handle: (params: MissingTranslationHandlerParams) => string;

                class MissingTranslationHandler

                abstract class MissingTranslationHandler {}

                  method handle

                  abstract handle: (params: MissingTranslationHandlerParams) => any;
                  • A function that handles missing translations.

                    Parameter params

                    context for resolving a missing translation

                    Returns

                    a value or an observable If it returns a value, then this value is used. If it return an observable, the value returned by this observable will be used (except if the method was "instant"). If it doesn't return then the key will be used as a value

                  class TranslateCompiler

                  abstract class TranslateCompiler {}

                    method compile

                    abstract compile: (value: string, lang: string) => string | Function;

                      method compileTranslations

                      abstract compileTranslations: (translations: any, lang: string) => any;

                        class TranslateDefaultParser

                        class TranslateDefaultParser extends TranslateParser {}

                          property ɵfac

                          static ɵfac: i0.ɵɵFactoryDeclaration<TranslateDefaultParser, never>;

                            property ɵprov

                            static ɵprov: i0.ɵɵInjectableDeclaration<TranslateDefaultParser>;

                              property templateMatcher

                              templateMatcher: RegExp;

                                method getValue

                                getValue: (target: any, key: string) => any;

                                  method interpolate

                                  interpolate: (expr: string | Function, params?: any) => string;

                                    class TranslateDirective

                                    class TranslateDirective implements AfterViewChecked, OnDestroy {}

                                      constructor

                                      constructor(
                                      translateService: TranslateService,
                                      element: ElementRef,
                                      _ref: ChangeDetectorRef
                                      );

                                        property currentParams

                                        currentParams: any;

                                          property key

                                          key: string;

                                            property lastParams

                                            lastParams: any;

                                              property onDefaultLangChangeSub

                                              onDefaultLangChangeSub: Subscription;

                                                property onLangChangeSub

                                                onLangChangeSub: Subscription;

                                                  property onTranslationChangeSub

                                                  onTranslationChangeSub: Subscription;

                                                    property ɵdir

                                                    static ɵdir: i0.ɵɵDirectiveDeclaration<
                                                    TranslateDirective,
                                                    '[translate],[ngx-translate]',
                                                    never,
                                                    { translate: 'translate'; translateParams: 'translateParams' },
                                                    {},
                                                    never
                                                    >;

                                                      property ɵfac

                                                      static ɵfac: i0.ɵɵFactoryDeclaration<TranslateDirective, never>;

                                                        method checkNodes

                                                        checkNodes: (forceUpdate?: boolean, translations?: any) => void;

                                                          method getContent

                                                          getContent: (node: any) => string;

                                                            method ngAfterViewChecked

                                                            ngAfterViewChecked: () => void;

                                                              method ngOnDestroy

                                                              ngOnDestroy: () => void;

                                                                method setContent

                                                                setContent: (node: any, content: string) => void;

                                                                  method updateValue

                                                                  updateValue: (key: string, node: any, translations: any) => void;

                                                                    class TranslateFakeCompiler

                                                                    class TranslateFakeCompiler extends TranslateCompiler {}
                                                                    • This compiler is just a placeholder that does nothing, in case you don't need a compiler at all

                                                                    property ɵfac

                                                                    static ɵfac: i0.ɵɵFactoryDeclaration<TranslateFakeCompiler, never>;

                                                                      property ɵprov

                                                                      static ɵprov: i0.ɵɵInjectableDeclaration<TranslateFakeCompiler>;

                                                                        method compile

                                                                        compile: (value: string, lang: string) => string | Function;

                                                                          method compileTranslations

                                                                          compileTranslations: (translations: any, lang: string) => any;

                                                                            class TranslateFakeLoader

                                                                            class TranslateFakeLoader extends TranslateLoader {}
                                                                            • This loader is just a placeholder that does nothing, in case you don't need a loader at all

                                                                            property ɵfac

                                                                            static ɵfac: i0.ɵɵFactoryDeclaration<TranslateFakeLoader, never>;

                                                                              property ɵprov

                                                                              static ɵprov: i0.ɵɵInjectableDeclaration<TranslateFakeLoader>;

                                                                                method getTranslation

                                                                                getTranslation: (lang: string) => Observable<any>;

                                                                                  class TranslateLoader

                                                                                  abstract class TranslateLoader {}

                                                                                    method getTranslation

                                                                                    abstract getTranslation: (lang: string) => Observable<any>;

                                                                                      class TranslateModule

                                                                                      class TranslateModule {}

                                                                                        property ɵfac

                                                                                        static ɵfac: i0.ɵɵFactoryDeclaration<TranslateModule, never>;

                                                                                          property ɵinj

                                                                                          static ɵinj: i0.ɵɵInjectorDeclaration<TranslateModule>;

                                                                                            property ɵmod

                                                                                            static ɵmod: i0.ɵɵNgModuleDeclaration<
                                                                                            TranslateModule,
                                                                                            [typeof i1.TranslatePipe, typeof i2.TranslateDirective],
                                                                                            never,
                                                                                            [typeof i1.TranslatePipe, typeof i2.TranslateDirective]
                                                                                            >;

                                                                                              method forChild

                                                                                              static forChild: (
                                                                                              config?: TranslateModuleConfig
                                                                                              ) => ModuleWithProviders<TranslateModule>;
                                                                                              • Use this method in your other (non root) modules to import the directive/pipe

                                                                                              method forRoot

                                                                                              static forRoot: (
                                                                                              config?: TranslateModuleConfig
                                                                                              ) => ModuleWithProviders<TranslateModule>;
                                                                                              • Use this method in your root module to provide the TranslateService

                                                                                              class TranslateParser

                                                                                              abstract class TranslateParser {}

                                                                                                method getValue

                                                                                                abstract getValue: (target: any, key: string) => any;
                                                                                                • Gets a value from an object by composed key parser.getValue({ key1: { keyA: 'valueI' }}, 'key1.keyA') ==> 'valueI'

                                                                                                  Parameter target

                                                                                                  Parameter key

                                                                                                method interpolate

                                                                                                abstract interpolate: (
                                                                                                expr: string | Function,
                                                                                                params?: any
                                                                                                ) => string | undefined;
                                                                                                • Interpolates a string to replace parameters "This is a {{ key }}" ==> "This is a value", with params = { key: "value" }

                                                                                                  Parameter expr

                                                                                                  Parameter params

                                                                                                class TranslatePipe

                                                                                                class TranslatePipe implements PipeTransform, OnDestroy {}

                                                                                                  constructor

                                                                                                  constructor(translate: TranslateService, _ref: ChangeDetectorRef);

                                                                                                    property lastKey

                                                                                                    lastKey: string;

                                                                                                      property lastParams

                                                                                                      lastParams: any[];

                                                                                                        property onDefaultLangChange

                                                                                                        onDefaultLangChange: any;

                                                                                                          property onLangChange

                                                                                                          onLangChange: any;

                                                                                                            property onTranslationChange

                                                                                                            onTranslationChange: any;

                                                                                                              property ɵfac

                                                                                                              static ɵfac: i0.ɵɵFactoryDeclaration<TranslatePipe, never>;

                                                                                                                property ɵpipe

                                                                                                                static ɵpipe: i0.ɵɵPipeDeclaration<TranslatePipe, 'translate'>;

                                                                                                                  property ɵprov

                                                                                                                  static ɵprov: i0.ɵɵInjectableDeclaration<TranslatePipe>;

                                                                                                                    property value

                                                                                                                    value: string;

                                                                                                                      method ngOnDestroy

                                                                                                                      ngOnDestroy: () => void;

                                                                                                                        method transform

                                                                                                                        transform: (query: string, ...args: any[]) => any;

                                                                                                                          method updateValue

                                                                                                                          updateValue: (
                                                                                                                          key: string,
                                                                                                                          interpolateParams?: Object,
                                                                                                                          translations?: any
                                                                                                                          ) => void;

                                                                                                                            class TranslateService

                                                                                                                            class TranslateService {}

                                                                                                                              constructor

                                                                                                                              constructor(
                                                                                                                              store: TranslateStore,
                                                                                                                              currentLoader: TranslateLoader,
                                                                                                                              compiler: TranslateCompiler,
                                                                                                                              parser: TranslateParser,
                                                                                                                              missingTranslationHandler: MissingTranslationHandler,
                                                                                                                              useDefaultLang: boolean,
                                                                                                                              isolate: boolean,
                                                                                                                              extend: boolean,
                                                                                                                              defaultLanguage: string
                                                                                                                              );
                                                                                                                              • Parameter store

                                                                                                                                an instance of the store (that is supposed to be unique)

                                                                                                                                Parameter currentLoader

                                                                                                                                An instance of the loader currently used

                                                                                                                                Parameter compiler

                                                                                                                                An instance of the compiler currently used

                                                                                                                                Parameter parser

                                                                                                                                An instance of the parser currently used

                                                                                                                                Parameter missingTranslationHandler

                                                                                                                                A handler for missing translations.

                                                                                                                                Parameter useDefaultLang

                                                                                                                                whether we should use default language translation when current language translation is missing.

                                                                                                                                Parameter isolate

                                                                                                                                whether this service should use the store or not

                                                                                                                                Parameter extend

                                                                                                                                To make a child module extend (and use) translations from parent modules.

                                                                                                                                Parameter defaultLanguage

                                                                                                                                Set the default language using configuration

                                                                                                                              property compiler

                                                                                                                              compiler: TranslateCompiler;

                                                                                                                                property currentLang

                                                                                                                                currentLang: string;
                                                                                                                                • The lang currently used

                                                                                                                                property currentLoader

                                                                                                                                currentLoader: TranslateLoader;

                                                                                                                                  property defaultLang

                                                                                                                                  defaultLang: string;
                                                                                                                                  • The default lang to fallback when translations are missing on the current lang

                                                                                                                                  property langs

                                                                                                                                  langs: string[];
                                                                                                                                  • an array of langs

                                                                                                                                  property missingTranslationHandler

                                                                                                                                  missingTranslationHandler: MissingTranslationHandler;

                                                                                                                                    property onDefaultLangChange

                                                                                                                                    readonly onDefaultLangChange: EventEmitter<DefaultLangChangeEvent>;
                                                                                                                                    • An EventEmitter to listen to default lang change events onDefaultLangChange.subscribe((params: DefaultLangChangeEvent) => { // do something });

                                                                                                                                    property onLangChange

                                                                                                                                    readonly onLangChange: EventEmitter<LangChangeEvent>;
                                                                                                                                    • An EventEmitter to listen to lang change events onLangChange.subscribe((params: LangChangeEvent) => { // do something });

                                                                                                                                    property onTranslationChange

                                                                                                                                    readonly onTranslationChange: EventEmitter<TranslationChangeEvent>;
                                                                                                                                    • An EventEmitter to listen to translation change events onTranslationChange.subscribe((params: TranslationChangeEvent) => { // do something });

                                                                                                                                    property ɵfac

                                                                                                                                    static ɵfac: i0.ɵɵFactoryDeclaration<TranslateService, never>;

                                                                                                                                      property ɵprov

                                                                                                                                      static ɵprov: i0.ɵɵInjectableDeclaration<TranslateService>;

                                                                                                                                        property parser

                                                                                                                                        parser: TranslateParser;

                                                                                                                                          property store

                                                                                                                                          store: TranslateStore;

                                                                                                                                            property translations

                                                                                                                                            translations: any;
                                                                                                                                            • a list of translations per lang

                                                                                                                                            method addLangs

                                                                                                                                            addLangs: (langs: Array<string>) => void;
                                                                                                                                            • Add available langs

                                                                                                                                            method get

                                                                                                                                            get: (
                                                                                                                                            key: string | Array<string>,
                                                                                                                                            interpolateParams?: Object
                                                                                                                                            ) => Observable<any>;
                                                                                                                                            • Gets the translated value of a key (or an array of keys)

                                                                                                                                              Returns

                                                                                                                                              the translated key, or an object of translated keys

                                                                                                                                            method getBrowserCultureLang

                                                                                                                                            getBrowserCultureLang: () => string | undefined;
                                                                                                                                            • Returns the culture language code name from the browser, e.g. "de-DE"

                                                                                                                                            method getBrowserLang

                                                                                                                                            getBrowserLang: () => string | undefined;
                                                                                                                                            • Returns the language code name from the browser, e.g. "de"

                                                                                                                                            method getDefaultLang

                                                                                                                                            getDefaultLang: () => string;
                                                                                                                                            • Gets the default language used

                                                                                                                                            method getLangs

                                                                                                                                            getLangs: () => Array<string>;
                                                                                                                                            • Returns an array of currently available langs

                                                                                                                                            method getParsedResult

                                                                                                                                            getParsedResult: (
                                                                                                                                            translations: any,
                                                                                                                                            key: any,
                                                                                                                                            interpolateParams?: Object
                                                                                                                                            ) => any;
                                                                                                                                            • Returns the parsed result of the translations

                                                                                                                                            method getStreamOnTranslationChange

                                                                                                                                            getStreamOnTranslationChange: (
                                                                                                                                            key: string | Array<string>,
                                                                                                                                            interpolateParams?: Object
                                                                                                                                            ) => Observable<any>;
                                                                                                                                            • Returns a stream of translated values of a key (or an array of keys) which updates whenever the translation changes.

                                                                                                                                              Returns

                                                                                                                                              A stream of the translated key, or an object of translated keys

                                                                                                                                            method getTranslation

                                                                                                                                            getTranslation: (lang: string) => Observable<any>;
                                                                                                                                            • Gets an object of translations for a given language with the current loader and passes it through the compiler

                                                                                                                                            method instant

                                                                                                                                            instant: (
                                                                                                                                            key: string | Array<string>,
                                                                                                                                            interpolateParams?: Object
                                                                                                                                            ) => string | any;
                                                                                                                                            • Returns a translation instantly from the internal state of loaded translation. All rules regarding the current language, the preferred language of even fallback languages will be used except any promise handling.

                                                                                                                                            method reloadLang

                                                                                                                                            reloadLang: (lang: string) => Observable<any>;
                                                                                                                                            • Allows to reload the lang file from the file

                                                                                                                                            method resetLang

                                                                                                                                            resetLang: (lang: string) => void;
                                                                                                                                            • Deletes inner translation

                                                                                                                                            method set

                                                                                                                                            set: (key: string, value: string, lang?: string) => void;
                                                                                                                                            • Sets the translated value of a key, after compiling it

                                                                                                                                            method setDefaultLang

                                                                                                                                            setDefaultLang: (lang: string) => void;
                                                                                                                                            • Sets the default language to use as a fallback

                                                                                                                                            method setTranslation

                                                                                                                                            setTranslation: (
                                                                                                                                            lang: string,
                                                                                                                                            translations: Object,
                                                                                                                                            shouldMerge?: boolean
                                                                                                                                            ) => void;
                                                                                                                                            • Manually sets an object of translations for a given language after passing it through the compiler

                                                                                                                                            method stream

                                                                                                                                            stream: (
                                                                                                                                            key: string | Array<string>,
                                                                                                                                            interpolateParams?: Object
                                                                                                                                            ) => Observable<any>;
                                                                                                                                            • Returns a stream of translated values of a key (or an array of keys) which updates whenever the language changes.

                                                                                                                                              Returns

                                                                                                                                              A stream of the translated key, or an object of translated keys

                                                                                                                                            method use

                                                                                                                                            use: (lang: string) => Observable<any>;
                                                                                                                                            • Changes the lang currently used

                                                                                                                                            class TranslateStore

                                                                                                                                            class TranslateStore {}

                                                                                                                                              property currentLang

                                                                                                                                              currentLang: string;
                                                                                                                                              • The lang currently used

                                                                                                                                              property defaultLang

                                                                                                                                              defaultLang: string;
                                                                                                                                              • The default lang to fallback when translations are missing on the current lang

                                                                                                                                              property langs

                                                                                                                                              langs: string[];
                                                                                                                                              • an array of langs

                                                                                                                                              property onDefaultLangChange

                                                                                                                                              onDefaultLangChange: EventEmitter<DefaultLangChangeEvent>;
                                                                                                                                              • An EventEmitter to listen to default lang change events onDefaultLangChange.subscribe((params: DefaultLangChangeEvent) => { // do something });

                                                                                                                                              property onLangChange

                                                                                                                                              onLangChange: EventEmitter<LangChangeEvent>;
                                                                                                                                              • An EventEmitter to listen to lang change events onLangChange.subscribe((params: LangChangeEvent) => { // do something });

                                                                                                                                              property onTranslationChange

                                                                                                                                              onTranslationChange: EventEmitter<TranslationChangeEvent>;
                                                                                                                                              • An EventEmitter to listen to translation change events onTranslationChange.subscribe((params: TranslationChangeEvent) => { // do something });

                                                                                                                                              property translations

                                                                                                                                              translations: any;
                                                                                                                                              • a list of translations per lang

                                                                                                                                              Interfaces

                                                                                                                                              interface DefaultLangChangeEvent

                                                                                                                                              interface DefaultLangChangeEvent {}

                                                                                                                                                property lang

                                                                                                                                                lang: string;

                                                                                                                                                  property translations

                                                                                                                                                  translations: any;

                                                                                                                                                    interface LangChangeEvent

                                                                                                                                                    interface LangChangeEvent {}

                                                                                                                                                      property lang

                                                                                                                                                      lang: string;

                                                                                                                                                        property translations

                                                                                                                                                        translations: any;

                                                                                                                                                          interface MissingTranslationHandlerParams

                                                                                                                                                          interface MissingTranslationHandlerParams {}

                                                                                                                                                            property interpolateParams

                                                                                                                                                            interpolateParams?: Object;
                                                                                                                                                            • interpolation params that were passed along for translating the given key.

                                                                                                                                                            property key

                                                                                                                                                            key: string;
                                                                                                                                                            • the key that's missing in translation files

                                                                                                                                                            property translateService

                                                                                                                                                            translateService: TranslateService;
                                                                                                                                                            • an instance of the service that was unable to translate the key.

                                                                                                                                                            interface TranslateModuleConfig

                                                                                                                                                            interface TranslateModuleConfig {}

                                                                                                                                                              property compiler

                                                                                                                                                              compiler?: Provider;

                                                                                                                                                                property defaultLanguage

                                                                                                                                                                defaultLanguage?: string;

                                                                                                                                                                  property extend

                                                                                                                                                                  extend?: boolean;

                                                                                                                                                                    property isolate

                                                                                                                                                                    isolate?: boolean;

                                                                                                                                                                      property loader

                                                                                                                                                                      loader?: Provider;

                                                                                                                                                                        property missingTranslationHandler

                                                                                                                                                                        missingTranslationHandler?: Provider;

                                                                                                                                                                          property parser

                                                                                                                                                                          parser?: Provider;

                                                                                                                                                                            property useDefaultLang

                                                                                                                                                                            useDefaultLang?: boolean;

                                                                                                                                                                              interface TranslationChangeEvent

                                                                                                                                                                              interface TranslationChangeEvent {}

                                                                                                                                                                                property lang

                                                                                                                                                                                lang: string;

                                                                                                                                                                                  property translations

                                                                                                                                                                                  translations: any;

                                                                                                                                                                                    Package Files (10)

                                                                                                                                                                                    Dependencies (1)

                                                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                                                    No dev dependencies.

                                                                                                                                                                                    Peer Dependencies (2)

                                                                                                                                                                                    Badge

                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ngx-translate/core.

                                                                                                                                                                                    • Markdown
                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ngx-translate/core)
                                                                                                                                                                                    • HTML
                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/@ngx-translate/core"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>