File

projects/congarevenuecloud/ecommerce/src/lib/services/translator-loader.service.ts

Description

This service is a work in progress This service is responsible for providing language translations for static text/labels in the application, based on user locale. If a user does not have a specified locale, translations will be determined based on the 'defaultLanguage' configured in the environment file.

Usage

import { TranslatorLoaderService } from '@congarevenuecloud/ecommerce';

constructor(private translateService: TranslatorLoaderService) {}

// or

export class MyService extends AObjectService {
private translateService: TranslatorLoaderService = this.injector.get(TranslatorLoaderService);
}

Index

Methods

Constructor

constructor(apiService: ApiService, storefrontService: StorefrontService, httpClient: HttpClient, configService: ConfigurationService)
Parameters :
Name Type Optional
apiService ApiService No
storefrontService StorefrontService No
httpClient HttpClient No
configService ConfigurationService No

Methods

getTranslation
getTranslation(locale: string, pageSize: number)

Retrieves translated labels based on current user's locale.

Example:

 import { TranslatorLoaderService, object } from '@congarevenuecloud/ecommerce';
 import { Observable } from 'rxjs/Observable';

 export class MyComponent implements OnInit {
     translations$:Observable<object>
     translations:object

     constructor(private translatorLoaderService: TranslatorLoaderService){}

       getTranslation(locale: string) {
           this.translations$ = this.translatorLoaderService.getTranslation(locale);
           //or
           this.translatorLoaderService.getTranslation(locale).subscribe(c=> this.translations= c);
        }
}

The default value is set to 2500.

Parameters :
Name Type Optional Default value Description
locale string No

parameter specifying the locale for translation.

pageSize number No 2500

optional parameter specifying the number of translations to fetch in a single request. The default value is set to 2500.

Returns : Observable<object>

an Observable containing the json string with translations.

results matching ""

    No results matching ""