@ngx-translate/core

  • Version 13.0.0
  • Published
  • 591 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: any;

    variable USE_DEFAULT_LANG

    const USE_DEFAULT_LANG: any;

      variable USE_EXTEND

      const USE_EXTEND: any;

        variable USE_STORE

        const USE_STORE: any;

          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

          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 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: any, _ref: any);

                                property currentParams

                                currentParams: any;

                                  property key

                                  key: string;

                                    property lastParams

                                    lastParams: any;

                                      property onDefaultLangChangeSub

                                      onDefaultLangChangeSub: any;

                                        property onLangChangeSub

                                        onLangChangeSub: any;

                                          property onTranslationChangeSub

                                          onTranslationChangeSub: any;

                                            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

                                                        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

                                                            method getTranslation

                                                            getTranslation: (lang: string) => any;

                                                              class TranslateLoader

                                                              abstract class TranslateLoader {}

                                                                method getTranslation

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

                                                                  class TranslateModule

                                                                  class TranslateModule {}

                                                                    method forChild

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

                                                                    method forRoot

                                                                    static forRoot: (config?: TranslateModuleConfig) => any;
                                                                    • 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;
                                                                      • 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: any);

                                                                          property lastKey

                                                                          lastKey: string;

                                                                            property lastParams

                                                                            lastParams: any[];

                                                                              property onDefaultLangChange

                                                                              onDefaultLangChange: any;

                                                                                property onLangChange

                                                                                onLangChange: any;

                                                                                  property onTranslationChange

                                                                                  onTranslationChange: any;

                                                                                    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: any;
                                                                                                    • An EventEmitter to listen to default lang change events onDefaultLangChange.subscribe((params: DefaultLangChangeEvent) => { // do something });

                                                                                                    property onLangChange

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

                                                                                                    property onTranslationChange

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

                                                                                                    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) => 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;
                                                                                                        • Returns the culture language code name from the browser, e.g. "de-DE"

                                                                                                        method getBrowserLang

                                                                                                        getBrowserLang: () => string;
                                                                                                        • 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
                                                                                                        ) => 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) => 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) => 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) => 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) => 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: any;
                                                                                                          • An EventEmitter to listen to default lang change events onDefaultLangChange.subscribe((params: DefaultLangChangeEvent) => { // do something });

                                                                                                          property onLangChange

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

                                                                                                          property onTranslationChange

                                                                                                          onTranslationChange: any;
                                                                                                          • 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>