TranslationService implements SingletonInterface

Advanced translations This class is subjected to change.

Do NOT subclass

Scope: frontend / backend

Internal
Attributes
#[Autoconfigure]
$public: true

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$languageServiceFactory  : LanguageServiceFactory
$locales  : Locales

Methods

__construct()  : mixed
translate()  : mixed
Returns the localized label of the LOCAL_LANG key, $key.
translateFinisherOption()  : string
translateFormElementError()  : string
translateFormElementValue()  : array<string|int, mixed>|string|null
translateToAllBackendLanguages()  : array<string|int, mixed>
translateValuesRecursive()  : array<string|int, mixed>
Recursively translate values.
isEmptyTranslatedValue()  : bool
Check if given translated value is considered "empty".
processTranslationChain()  : string|null
sortArrayWithIntegerKeysDescending()  : array<string|int, mixed>
If the array contains numerical keys only, sort it in descending order

Properties

Methods

translate()

Returns the localized label of the LOCAL_LANG key, $key.

public translate(mixed $key[, array<string|int, mixed>|null $arguments = null ][, string|null $locallangPathAndFilename = null ][, Locale|string|null $locale = null ][, mixed $defaultValue = '' ]) : mixed
Parameters
$key : mixed

The key from the LOCAL_LANG array for which to return the value.

$arguments : array<string|int, mixed>|null = null

the arguments of the extension, being passed over to vsprintf

$locallangPathAndFilename : string|null = null
$locale : Locale|string|null = null
$defaultValue : mixed = ''
Internal
Return values
mixed

The value from LOCAL_LANG or $defaultValue if no translation was found.

translateFinisherOption()

public translateFinisherOption(FormRuntime $formRuntime, string $finisherIdentifier, string $optionKey, string $optionValue[, array<string|int, mixed> $renderingOptions = [] ]) : string
Parameters
$formRuntime : FormRuntime
$finisherIdentifier : string
$optionKey : string
$optionValue : string
$renderingOptions : array<string|int, mixed> = []
Tags
throws
InvalidArgumentException
Return values
string

translateFormElementError()

public translateFormElementError(RootRenderableInterface $element, int $code, array<string|int, mixed> $arguments, string $defaultValue, FormRuntime $formRuntime) : string
Parameters
$element : RootRenderableInterface
$code : int
$arguments : array<string|int, mixed>
$defaultValue : string
$formRuntime : FormRuntime
Internal
Tags
throws
InvalidArgumentException
Return values
string

translateFormElementValue()

public translateFormElementValue(RootRenderableInterface $element, array<string|int, mixed> $propertyParts, FormRuntime $formRuntime[, Locale|string|null $locale = null ]) : array<string|int, mixed>|string|null
Parameters
$element : RootRenderableInterface
$propertyParts : array<string|int, mixed>
$formRuntime : FormRuntime
$locale : Locale|string|null = null
Internal
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>|string|null

translateToAllBackendLanguages()

public translateToAllBackendLanguages(string $key[, array<string|int, mixed>|null $arguments = null ][, array<string|int, mixed> $translationFiles = [] ]) : array<string|int, mixed>
Parameters
$key : string
$arguments : array<string|int, mixed>|null = null
$translationFiles : array<string|int, mixed> = []
Internal
Return values
array<string|int, mixed>

the modified array

translateValuesRecursive()

Recursively translate values.

public translateValuesRecursive(array<string|int, mixed> $array[, array<string|int, mixed> $translationFiles = [] ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$translationFiles : array<string|int, mixed> = []
Internal
Return values
array<string|int, mixed>

the modified array

isEmptyTranslatedValue()

Check if given translated value is considered "empty".

protected isEmptyTranslatedValue(mixed $translatedValue) : bool

A translated value is considered "empty" if it's either NULL or an empty string. This helper method exists to perform a less strict check than the native empty() function, because it is too strict in terms of supported translated values. For example, the value "0" is valid, whereas empty() would handle it as "empty" and therefore invalid.

Parameters
$translatedValue : mixed
Return values
bool

processTranslationChain()

protected processTranslationChain(array<string|int, mixed> $translationKeyChain[, Locale|string|null $locale = null ][, array<string|int, mixed>|null $arguments = null ]) : string|null
Parameters
$translationKeyChain : array<string|int, mixed>
$locale : Locale|string|null = null
$arguments : array<string|int, mixed>|null = null
Return values
string|null

sortArrayWithIntegerKeysDescending()

If the array contains numerical keys only, sort it in descending order

protected sortArrayWithIntegerKeysDescending(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results