LocalizationUtility
Localization helper which should be used to fetch localized labels.
Table of Contents
Methods
- translate() : string|null
- Returns the localized label of the LOCAL_LANG key, $key.
- getLocale() : Locale
- Resolves the currently active locale.
- getPluginName() : string
- Allow plugin.tx_myextension._LOCAL_LANG and plugin.tx_myextension_myplugin._LOCAL_LANG
Methods
translate()
Returns the localized label of the LOCAL_LANG key, $key.
public
static translate(string $key[, string|null $extensionName = null ][, array<string|int, mixed>|null $arguments = null ][, Locale|string|null $languageKey = null ][, ServerRequestInterface|null $request = null ]) : string|null
Parameters
- $key : string
-
The key from the LOCAL_LANG array for which to return the value.
- $extensionName : string|null = null
-
The name of the extension or domain name (such as "myextension.messages")
- $arguments : array<string|int, mixed>|null = null
-
The arguments of the label, being passed over to sprintf
- $languageKey : Locale|string|null = null
-
The language key or null for using the current language from the system
- $request : ServerRequestInterface|null = null
Return values
string|null —The value from LOCAL_LANG or null if no translation was found.
getLocale()
Resolves the currently active locale.
protected
static getLocale(Locale|string|null $localeOrLanguageKey, ServerRequestInterface|null $request) : Locale
Using the Locales factory, as it handles dependencies (e.g. "de-AT" falls back to "de").
Parameters
- $localeOrLanguageKey : Locale|string|null
- $request : ServerRequestInterface|null
Return values
LocalegetPluginName()
Allow plugin.tx_myextension._LOCAL_LANG and plugin.tx_myextension_myplugin._LOCAL_LANG
protected
static getPluginName(ServerRequestInterface|null $request) : string
Parameters
- $request : ServerRequestInterface|null