File

lib/common/src/translations/ng/translations.service.ts

Description

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.

Extends

TranslationService

Index

Properties
Methods

Constructor

constructor(translators: Translator[] | null)
Parameters :
Name Type Optional
translators Translator[] | null No

Methods

Public addTranslator
addTranslator(translator: Translator)
Inherited from TranslationService

Adds a translator to the pool of translators. Checks if the translator is compatible with at least one language.

Parameters :
Name Type Optional
translator Translator No
Returns : void
getMatchingTranslator
getMatchingTranslator(input)
Inherited from TranslationService

Find all matching translators for the given input and returns them in order of their matching score (best first).

Parameters :
Name Optional
input No
Returns : Translator[]
getTranslationData
getTranslationData(input, param?: Record, language: string, recursionCount: number)
Inherited from TranslationService

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 :
Name Type Optional Default value
input No
param Record<string | > Yes
language string No this.activeLanguage
recursionCount number No 0
translate
translate(input, param?: Record, language: string)
Inherited from TranslationService

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 :
Name Type Optional Default value
input No
param Record<string | > Yes
language string No this.activeLanguage
Returns : string | null

Properties

Public activeLanguageChange$
Type : BehaviorSubject<string>
Inherited from TranslationService

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

This language will be used as initial active language.

Public translators
Type : Translator[]
Default value : []
Inherited from TranslationService

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')
	}
	
}






results matching ""

    No results matching ""