lib/common/src/translations/ng/translations.service.ts
This service manages all translation related tasks. For the most part this is only an angular wrapper for TranslationService.
In order to extend its capabilities use provideTranslators to register custom extensions of Translator.
The most prominent Translator is StringTranslator that translates message strings by the help of an extentable dictionary. You can use provideTranslationMap to provide your own messages and corresponding translations.
Properties |
|
Methods |
constructor(translators: Translator[] | null)
|
||||||
Parameters :
|
Public addTranslator | ||||||
addTranslator(translator: Translator)
|
||||||
Inherited from
TranslationService
|
||||||
Defined in
TranslationService:87
|
||||||
Adds a translator to the pool of translators. Checks if the translator is compatible with at least one language.
Parameters :
Returns :
void
|
getMatchingTranslator | ||||
getMatchingTranslator(input)
|
||||
Inherited from
TranslationService
|
||||
Defined in
TranslationService:155
|
||||
Find all matching translators for the given input and returns them in order of their matching score (best first).
Parameters :
Returns :
Translator[]
|
getTranslationData | ||||||||||||||||||||
getTranslationData(input, param?: Record
|
||||||||||||||||||||
Inherited from
TranslationService
|
||||||||||||||||||||
Defined in
TranslationService:183
|
||||||||||||||||||||
Tries to translate any given input, by finding a matching translator and returing that translator's translation. Returns the translation result and the associated Translator.
Parameters :
|
translate | ||||||||||||||||
translate(input, param?: Record
|
||||||||||||||||
Inherited from
TranslationService
|
||||||||||||||||
Defined in
TranslationService:217
|
||||||||||||||||
Tries to translate any given input, by finding a matching translator and returing that translator's translation. Returns null, if the input cannot be handled by any translator.
Parameters :
Returns :
string | null
|
Public activeLanguageChange$ |
Type : BehaviorSubject<string>
|
Inherited from
TranslationService
|
Defined in
TranslationService:41
|
The currently set language; all translations will default to this language, when no other language is specified. Languages are denoted by language code (i.e. 'en', 'de', 'fr', ...) Emits on subscribe and when the active language is switched to a new one. |
Public defaultLanguage |
Type : string
|
Default value : 'en'
|
Inherited from
TranslationService
|
Defined in
TranslationService:52
|
This language will be used as initial active language. |
Public translators |
Type : Translator[]
|
Default value : []
|
Inherited from
TranslationService
|
Defined in
TranslationService:47
|
Service instances of all registred Translators. |
import {
Inject,
Injectable,
Optional,
} from '@angular/core'
import {
Translator,
TranslationService
} from '../nong'
import {
TRANSLATORS
} from './translations.commons'
//TODO settings
/**
* This service manages all translation related tasks. For the most part this is only an angular wrapper for {@link TranslationService}.
*
* In order to extend its capabilities use {@link provideTranslators} to register
* custom extensions of {@link Translator}.
*
* The most prominent Translator is {@link StringTranslator} that translates message strings by the help of an extentable dictionary.
* You can use {@link provideTranslationMap} to provide your own messages and corresponding translations.
*
*/
@Injectable()
export class RccTranslationService extends TranslationService {
constructor(
@Optional() @Inject(TRANSLATORS)
translators : Translator[] | null,
){
super(translators , 'en')
}
}