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

Example :
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)

Retrieves translated labels based on current user's locale.

Example:

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);
}
Parameters :
Name Type Optional Description
locale string No

parameter specifying the locale for translation.

Returns : Observable<object>

an Observable containing the json string with translations.

results matching ""

    No results matching ""