File

src/tools/localization.service.ts

Description

Service which is wrapping the configuration logic of TranslateService from ngx-translate Any application willing to use localization just needs to inject LocalizationService in the root component and call its configure() method.

Index

Properties
Methods
Accessors

Constructor

constructor(translateService: TranslateService, logger: LoggerService, configuration: LocalizationConfiguration, store?: Store<LocalizationOverrideStore>)
Parameters :
Name Type Optional
translateService TranslateService No
logger LoggerService No
configuration LocalizationConfiguration No
store Store<LocalizationOverrideStore> Yes

Methods

Public configure
configure()

Configures TranslateService and registers locales. This method is called from the application level.

Returns : void
Public getCurrentLanguage
getCurrentLanguage()

Wrapper to get the ngx-translate service TranslateService currentLang.

Returns : any
Public getKey
getKey(requestedKey: string)

Get an observable of translation key after global mapping

Parameters :
Name Type Optional Description
requestedKey string No

Original translation key

Returns : any
Public getLanguages
getLanguages()

Wrapper to call the ngx-translate service TranslateService method getLangs().

Returns : any
Public getTranslateService
getTranslateService()

Get the instance of the ngx-translate TranslateService used by LocalizationService.

Returns : TranslateService
Public isTranslationDeactivationEnabled
isTranslationDeactivationEnabled()

Is the translation deactivation enabled

Returns : any
Public toggleShowKeys
toggleShowKeys(value?: boolean)

Toggle the ShowKeys mode between active and inactive.

Parameters :
Name Type Optional Description
value boolean Yes

if specified, set the ShowKeys mode to value. If not specified, toggle the ShowKeys mode.

Returns : void
Public translate
translate(key: string, interpolateParams?: object)

Returns a stream of translated values of a key which updates whenever the language changes.

Parameters :
Name Type Optional Description
key string No

Key to translate

interpolateParams object Yes

Object to use in translation binding

Returns : any

A stream of the translated key

Public useLanguage
useLanguage(language: string)

Wrapper to call the ngx-translate service TranslateService method use(language).

Parameters :
Name Type Optional
language string No
Returns : Observable<any>

Properties

Public showKeys$
Default value : this._showKeys$.asObservable()

_showKeys$ exposed as an Observable

Accessors

showKeys
getshowKeys()

Return the current value of debug show/hide translation keys.

results matching ""

    No results matching ""