class FileAdapter (View source)

A model representing data from an XLIFF file object that may be distributed over several documents in different versions.

Please note that plural forms for particular translation unit are accessed with integer index (and not string like 'zero', 'one', 'many' etc). This is because they are indexed such way in XLIFF files in order to not break tools' support.

There are very few XLIFF editors, but they are nice Gettext's .po editors available. Gettext supports plural forms, but it indexes them using integer numbers. Leaving it this way in .xlf files, makes it possible to easily convert them to .po (e.g. using xliff2po from Translation Toolkit), edit with Poedit, and convert back to .xlf without any information loss (using po2xliff).

Properties

protected LoggerInterface $i18nLogger
protected array $fileData
protected Locale $requestedLocale

Methods

__construct(array $fileData, Locale $requestedLocale)

No description

mixed
getTargetBySource(string $source, int $pluralFormIndex = 0)

Returns translated label ("target" tag in XLIFF) from source-target pair where "source" tag equals to $source parameter.

mixed
getTargetByTransUnitId(string $transUnitId, int $pluralFormIndex = 0)

Returns translated label ("target" tag in XLIFF) for the id given.

array
getTranslationUnits()

No description

Details

__construct(array $fileData, Locale $requestedLocale)

No description

Parameters

array $fileData
Locale $requestedLocale

mixed getTargetBySource(string $source, int $pluralFormIndex = 0)

Returns translated label ("target" tag in XLIFF) from source-target pair where "source" tag equals to $source parameter.

Parameters

string $source

Label in original language ("source" tag in XLIFF)

int $pluralFormIndex

Index of plural form to use (starts with 0)

Return Value

mixed

Translated label or false on failure

mixed getTargetByTransUnitId(string $transUnitId, int $pluralFormIndex = 0)

Returns translated label ("target" tag in XLIFF) for the id given.

Id is compared with "id" attribute of "trans-unit" tag (see XLIFF specification for details).

Parameters

string $transUnitId

The "id" attribute of "trans-unit" tag in XLIFF

int $pluralFormIndex

Index of plural form to use (starts with 0)

Return Value

mixed

Translated label or false on failure

array getTranslationUnits()

No description

Return Value

array