LabelFileResolver

Read onlyYes

Service class for resolving label file paths and determining loading order.

This class handles:

  • Path resolving for localization files
  • File name resolving with language variants
  • Detecting resource override files via $GLOBALS['TYPO3_CONF_VARS']['LANG']['resourceOverrides']
  • Determining file loading order without merging content
Internal

not part of TYPO3's public API.

Attributes
#[Autoconfigure]
$public: true

Table of Contents

Properties

$packageManager  : PackageManager

Methods

__construct()  : mixed
getOverrideFilePaths()  : array<string|int, string>
Get override file paths for localization
resolveFileReference()  : string
getAbsoluteFileReference()  : string
Get absolute file reference
getFileReferenceWithoutExtension()  : string
Get file reference without extension
getLocalizedLabelsPathPattern()  : string
Get localized labels path pattern for extensions
getSupportedExtensions()  : array<string|int, mixed>
resolveExtensionResourcePath()  : string
resolveLocalizedFilePath()  : string
Resolve localized file path by trying multiple location strategies.

Properties

Methods

getOverrideFilePaths()

Get override file paths for localization

public getOverrideFilePaths(string $fileReference, string $locale) : array<string|int, string>

This method returns an array of override file paths that should be loaded for the given file reference and language key

Parameters
$fileReference : string
$locale : string
Return values
array<string|int, string>

Array of absolute file paths to override files

resolveFileReference()

public resolveFileReference(string $fileReference, string $locale[, bool $useDefault = true ]) : string
Parameters
$fileReference : string
$locale : string
$useDefault : bool = true
Return values
string

getAbsoluteFileReference()

Get absolute file reference

protected getAbsoluteFileReference(string $fileReference) : string
Parameters
$fileReference : string
Return values
string

getFileReferenceWithoutExtension()

Get file reference without extension

protected getFileReferenceWithoutExtension(string $fileReference) : string
Parameters
$fileReference : string
Return values
string

getLocalizedLabelsPathPattern()

Get localized labels path pattern for extensions

protected getLocalizedLabelsPathPattern(string $fileReference) : string
Parameters
$fileReference : string
Return values
string

getSupportedExtensions()

protected getSupportedExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>

resolveExtensionResourcePath()

protected resolveExtensionResourcePath(string $sourcePath, string $locale, string $fileReference) : string
Parameters
$sourcePath : string
$locale : string
$fileReference : string
Return values
string

resolveLocalizedFilePath()

Resolve localized file path by trying multiple location strategies.

protected resolveLocalizedFilePath(string $sourcePath, string $locale) : string

This method attempts to find localized versions of files in the following order:

  1. Check if the file already has the correct locale prefix (early return)
  2. Try same directory with locale prefix: "de.locallang.xlf" in same folder
  3. Try TYPO3 labels directory structure: "/var/labels/de/extension_key/path/de.filename.xlf"

Language variant handling:

  • Supports both underscore and hyphen variants: "de_CH" <-> "de-CH"
  • Tests both formats when resolving files

Examples:

  • Source: "/ext/core/Resources/Private/Language/locallang.xlf"
  • For locale "de": tries "de.locallang.xlf" in same dir, then "/var/labels/de/core/de.locallang.xlf"
  • For locale "de-CH": tries both "de-CH.locallang.xlf" and "de_CH.locallang.xlf" variants
Parameters
$sourcePath : string

Absolute path to the source localization file

$locale : string

Language locale (e.g., "de", "de-CH", "de_AT")

Return values
string

Absolute path to the localized file, or original path if not found


        
On this page

Search results