### File

`projects/angular-l10n/src/lib/services/l10n-translation-loader.ts`

### Description

Implement this class-interface to create a loader of translation data.

### Index

###### Methods

- Public Abstract get

### Methods

Public Abstract get
`get(language: string, provider: L10nProvider)`
Defined in projects/angular-l10n/src/lib/services/l10n-translation-loader.ts:18

This method must contain the logic to get translation data.

Parameters :

Name | Type | Optional | Description
language | `string` | No | The current language
provider | `L10nProvider` | No | The provider of the translations data

Returns : `Observable<literal type>`

An object of translation data for the language: {key: value}

    import { Injectable } from '@angular/core';
    import { Observable, of, throwError } from 'rxjs';

    import { L10nProvider } from '../models/types';
    import { l10nError } from '../models/l10n-error';

    /**
     * Implement this class-interface to create a loader of translation data.
     */
    @Injectable() export abstract class L10nTranslationLoader {

        /**
         * This method must contain the logic to get translation data.
         * @param language The current language
         * @param provider The provider of the translations data
         * @return An object of translation data for the language: {key: value}
         */
        public abstract get(language: string, provider: L10nProvider): Observable<{ [key: string]: any }>;

    }

    @Injectable() export class L10nDefaultTranslationLoader implements L10nTranslationLoader {

        public get(language: string, provider: L10nProvider): Observable<{ [key: string]: any }> {
            return provider.asset[language] ?
                of(provider.asset[language]) :
                throwError(l10nError(L10nDefaultTranslationLoader, 'Asset not found'));
        }

    }

# result-matching ""

# No results matching ""