File

projects/openvidu-components-angular/src/lib/services/translate/translate.service.ts

Description

Service responsible for managing translations for the application. This service provides methods to add additional translations and to translate keys into the currently selected language.

The pipe TranslatePipe is used to translate keys in the templates.

Index

Properties
Methods

Constructor

constructor(storageService: StorageService)
Parameters :
Name Type Optional
storageService StorageService No

Methods

addTranslations
addTranslations(translations: Partial<AdditionalTranslationsType>)

Adds multiple translations to the additional translations storage.

Parameters :
Name Type Optional Description
translations Partial<AdditionalTranslationsType> No
  • A record where each key is a language code and the value is an object of translations for that language.
Returns : void
getAvailableLanguages
getAvailableLanguages()

Retrieves the list of all available language options.

Returns : LangOption[]

An array of available language options.

translate
translate(key: string)

Translates a given key into the current language.

This method first attempts to find the translation in the official translations. If the translation is not found, it then looks for the translation in the additional translations registered by the app.

Parameters :
Name Type Optional Description
key string No
  • The key to be translated.
Returns : string

The translated string if found, otherwise an empty string.

Properties

selectedLanguageOption$
Type : Observable<LangOption>

results matching ""

    No results matching ""