@ngx-translate/http-loader

  • Version 18.1.0
  • Published
  • 20.6 kB
  • 1 dependency
  • MIT license

Install

npm i @ngx-translate/http-loader
yarn add @ngx-translate/http-loader
pnpm add @ngx-translate/http-loader

Overview

http loader for dynamically loading translation files for @ngx-translate/core

Index

Variables

variable TRANSLATE_HTTP_LOADER_CONFIG

const TRANSLATE_HTTP_LOADER_CONFIG: InjectionToken<
Partial<TranslateMultiHttpLoaderConfig>
>;

    Functions

    function provideTranslateHttpLoader

    provideTranslateHttpLoader: (
    config?: Partial<TranslateHttpLoaderConfig | TranslateMultiHttpLoaderConfig>
    ) => Provider[];

      function provideTranslateMultiHttpLoader

      provideTranslateMultiHttpLoader: (
      config?: Partial<TranslateMultiHttpLoaderConfig>
      ) => Provider[];

        Classes

        class TranslateHttpLoader

        class TranslateHttpLoader implements TranslateLoader {}

          constructor

          constructor();

            property ɵfac

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

              property ɵprov

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

                method getTranslation

                getTranslation: (lang: string) => Observable<TranslationObject>;
                • Gets the translations from the server

                Interfaces

                interface TranslateHttpLoaderConfig

                interface TranslateHttpLoaderConfig {}

                  property enforceLoading

                  enforceLoading: boolean;

                    property failOnError

                    failOnError?: boolean;
                    • If true, a failed HTTP fetch (e.g. 404) propagates the error and fails the whole language load (v17 behaviour). If false (default), each resource failure is caught and replaced with an empty object, with a console.warn per failure; remaining resources still contribute their keys. Set this to true if you want deploys to fail loudly on a missing translation file rather than serve partial translations. Must be true for the translation service's retry option to retry HTTP failures.

                    property flatten

                    flatten?: boolean;
                    • Flatten each resource's nested objects into dotted keys before merging (default false). Later resources then override equivalent flat or nested keys. Arrays and null stay intact. Within one resource, the last encountered equivalent key wins.

                    property onLoadError

                    onLoadError?: (failure: TranslateHttpLoaderError) => void;
                    • Reports each failed resource attempt instead of the loader's default warning. Called in both failure modes; failOnError still controls error propagation. Exceptions from this callback are warned about without replacing the loading error. Does not suppress separate TranslateService warnings after a terminal loading failure.

                    property prefix

                    prefix?: string;

                      property suffix

                      suffix?: string;

                        property useHttpBackend

                        useHttpBackend: boolean;

                          interface TranslateHttpLoaderError

                          interface TranslateHttpLoaderError {}

                            property error

                            error: unknown;

                              property lang

                              lang: string;

                                property resource

                                resource: string | TranslateHttpLoaderResource;

                                  property url

                                  url: string | undefined;
                                  • The request URL, or undefined if language encoding failed before URL construction.

                                  interface TranslateHttpLoaderResource

                                  interface TranslateHttpLoaderResource {}

                                    property prefix

                                    prefix: string;

                                      property suffix

                                      suffix?: string;

                                        interface TranslateMultiHttpLoaderConfig

                                        interface TranslateMultiHttpLoaderConfig {}

                                          property enforceLoading

                                          enforceLoading: boolean;

                                            property failOnError

                                            failOnError?: boolean;

                                            property flatten

                                            flatten?: boolean;

                                            property onLoadError

                                            onLoadError?: (failure: TranslateHttpLoaderError) => void;

                                            property resources

                                            resources: (string | TranslateHttpLoaderResource)[];

                                              property useHttpBackend

                                              useHttpBackend: boolean;

                                                Package Files (1)

                                                Dependencies (1)

                                                Dev Dependencies (0)

                                                No dev dependencies.

                                                Peer Dependencies (3)

                                                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/http-loader.

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