File

libs/upp-base/src/modules/language.ts

Description

The service loads translation strings for various modules and supports switching between different languages. It also provides translation functionality with caching mechanisms for optimized performance.

Index

Properties
Methods
Accessors

Constructor

constructor(http: HttpClient, langspath: string, route: ActivatedRoute)
Parameters :
Name Type Optional Description
http HttpClient No
  • Angular HttpClient for fetching translation files.
langspath string No
  • The base path for translation JSON files.
route ActivatedRoute No
  • Angular ActivatedRoute for accessing URL parameters.

Methods

Public GetLanguage
GetLanguage(toUpper)
Parameters :
Name Optional Default value Description
toUpper No false
  • Whether to return the language code in uppercase.
Returns : string

The active language code, or the default language if no language is set.

Public GetLanguages
GetLanguages()
Returns : {}

An array of supported language objects.

Public Async LoadModule
LoadModule(name: string)
Parameters :
Name Type Optional Description
name string No
  • The name of the module to load.
Returns : Promise<boolean>

Resolves to true if the module was successfully loaded; otherwise, false.

Public Async SetLanguage
SetLanguage(language: string, global)
Parameters :
Name Type Optional Default value Description
language string No
  • The language code to add.
global No true
Returns : Promise<boolean>

Resolves to true if the language was successfully added; otherwise, false.

Public StrInfo
StrInfo(id: string)
Parameters :
Name Type Optional Description
id string No
  • The ID of the translation string.
Returns : any

Translation information, or null if the string ID is not found.

Public tr
tr(id: string, args: ___targs, language: string | null)
Parameters :
Name Type Optional Default value Description
id string No
  • The ID of the translation string.
args ___targs No []
  • Optional arguments to replace placeholders in the translation.
language string | null No null
  • Optional target language for the translation.
Returns : string

The translated string, or "..." if the language is still loading.

Properties

Public OnSetLanguage
Default value : this._onSetLanguage.asObservable()

Accessors

_strings
get_strings()

results matching ""

    No results matching ""