LocalizationFactory

This class acts currently as facade around SymfonyTranslator.

User-land code should use LanguageService for the time being, and this class should not be exposed directly.

Hand in the locale to load, or english ("default").

What it does:

  • Caches on a system-level cache
  • Caches on a runtime memory cache ($this->data) per file
  • Handles loading default (= english) before translated files
  • Handles file name juggling of translated files.
  • Handles localization overrides via $GLOBALS['TYPO3_CONF_VARS']['LANG']['resourceOverrides']

Table of Contents

Properties

$dataStore  : array<string, array<string, array<string, array<int, array<string, string>>>>>
In-memory store for parsed data to avoid re-parsing within the same request.
$labelFileResolver  : LabelFileResolver
$runtimeCache  : FrontendInterface
$systemCache  : FrontendInterface
$translator  : Translator

Methods

__construct()  : mixed
getParsedData()  : array<string, array<string, array<int, array<string, string>>>>
Returns parsed data from a given file and language key.
applyLocalizationOverrides()  : array<string|int, mixed>
Apply localization overrides by merging override file contents
convertCatalogueToLegacyFormat()  : array<string|int, mixed>
Convert Symfony MessageCatalogue to TYPO3's legacy format
getData()  : array<string|int, mixed>
Get all data for a file reference
getDataByLanguage()  : array<string|int, mixed>
Get data for a specific language
getMessageCatalogue()  : MessageCatalogueInterface
Load translations of one resource using Symfony Translator
hasData()  : bool
Check if data is available for the given file reference and language
loadWithSymfonyTranslator()  : array<string|int, mixed>
Get the catalogue and convert to TYPO3 format
parseIcuPlural()  : array<string|int, mixed>
Simple parser for ICU plural format - extracts plural values
setData()  : void
Set data for a file reference and language

Properties

$dataStore

In-memory store for parsed data to avoid re-parsing within the same request.

protected array<string, array<string, array<string, array<int, array<string, string>>>>> $dataStore = []

$translator read-only

protected Translator $translator

Methods

getParsedData()

Returns parsed data from a given file and language key.

public getParsedData(string $fileReference, string $languageKey) : array<string, array<string, array<int, array<string, string>>>>
Parameters
$fileReference : string

Input is a file-reference (see \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName). That file is expected to be a supported locallang file format

$languageKey : string

Language key

Return values
array<string, array<string, array<int, array<string, string>>>>

applyLocalizationOverrides()

Apply localization overrides by merging override file contents

protected applyLocalizationOverrides(string $fileReference, string $languageKey, array<string|int, mixed> $labels) : array<string|int, mixed>
Parameters
$fileReference : string
$languageKey : string
$labels : array<string|int, mixed>
Return values
array<string|int, mixed>

convertCatalogueToLegacyFormat()

Convert Symfony MessageCatalogue to TYPO3's legacy format

protected convertCatalogueToLegacyFormat(MessageCatalogueInterface $catalogue, string $languageKey, MessageCatalogueInterface $fallbackCatalogue) : array<string|int, mixed>
Parameters
$catalogue : MessageCatalogueInterface
$languageKey : string
$fallbackCatalogue : MessageCatalogueInterface
Return values
array<string|int, mixed>

getData()

Get all data for a file reference

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

getDataByLanguage()

Get data for a specific language

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

getMessageCatalogue()

Load translations of one resource using Symfony Translator

protected getMessageCatalogue(string $fileReference, string $locale[, bool $useDefault = true ]) : MessageCatalogueInterface
Parameters
$fileReference : string
$locale : string
$useDefault : bool = true
Return values
MessageCatalogueInterface

hasData()

Check if data is available for the given file reference and language

protected hasData(string $fileReference, string $languageKey) : bool
Parameters
$fileReference : string
$languageKey : string
Return values
bool

loadWithSymfonyTranslator()

Get the catalogue and convert to TYPO3 format

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

parseIcuPlural()

Simple parser for ICU plural format - extracts plural values

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

setData()

Set data for a file reference and language

protected setData(string $fileReference, string $languageKey, array<string|int, mixed> $data) : void
Parameters
$fileReference : string
$languageKey : string
$data : array<string|int, mixed>

        
On this page

Search results