File

core/i18n/translate.service.ts

Description

A service to manage the language of the application.

Index

Properties
Methods

Constructor

constructor(ngxTranslate: NgxTranslateService, ui: AppStateService, options: OptionsService, document: Document, bsLocaleService: BsLocaleService)
Parameters :
Name Type Optional
ngxTranslate NgxTranslateService No
ui AppStateService No
options OptionsService No
document Document No
bsLocaleService BsLocaleService No

Methods

convertToLanguageCodePO
convertToLanguageCodePO(lang: string)

Converts a iso language code to a PO language code (e.g. de-de gets de_de).

Parameters :
Name Type Optional Description
lang string No

The iso language code.

Returns : string
Static defaultLang
defaultLang()
Returns : any
firstSupportedLanguage
firstSupportedLanguage()

Finds the first supported language

Returns : any
getNativeLanguage
getNativeLanguage(lang: string)

Returns the language in the native language.

Parameters :
Name Type Optional Description
lang string No

The language two-letter code.

Returns : string

The native name.

getSupported
getSupported(localeCode: string)
Parameters :
Name Type Optional
localeCode string No
Returns : any
Async loadLocales
loadLocales(moduleLang)
Parameters :
Name Optional
moduleLang No
Returns : any
queryStringLang
queryStringLang()

Gets the language from the query parameter.

Returns : any

The language two-letter code.

saveInLocalStorage
saveInLocalStorage(lang: string)
Parameters :
Name Type Optional
lang string No
Returns : void
setLanguage
setLanguage(lang: string)
Parameters :
Name Type Optional
lang string No
Returns : void
Async switchToLanguage
switchToLanguage(localeCode: string)

Switches the app to given locale (incl. Angular, Bootstrap, translations).

  • two-letter codes for language only, for example: en, de
  • four-letter codes for language and country, separated with underscore or dash, for example: zh_CN, zh_cn, zh-CN, zh-cn
Parameters :
Name Type Optional Description
localeCode string No

The locale code. Supported formats:

  • two-letter codes for language only, for example: en, de
  • four-letter codes for language and country, separated with underscore or dash, for example: zh_CN, zh_cn, zh-CN, zh-cn
Returns : any

Properties

langs
Type : any
Default value : keys(this.langsDetail).filter(k => this.langsDetail[k])
langsDetail
Type : any
Default value : this.options.get('languages', {})
Static SAVE_LANGUAGE_KEY
Type : string
Default value : 'c8y_language'

results matching ""

    No results matching ""