Documentation

XliffFileLoader
in package
implements LoaderInterface

XliffFileLoader loads translations from XLIFF files.

Tags
author

Fabien Potencier fabien@symfony.com

Interfaces, Classes and Traits

LoaderInterface
LoaderInterface is the interface implemented by all translation loaders.

Table of Contents

load()  : MessageCatalogue
Loads a locale.
extract()  : mixed
extractXliff1()  : mixed
Extract messages and metadata from DOMDocument into a MessageCatalogue.
extractXliff2()  : mixed
fixXmlLocation()  : string
Internally changes the URI of a dependent xsd to be loaded locally.
getSchema()  : mixed
getVersionNumber()  : string
Gets xliff file version based on the root "version" attribute.
getXmlErrors()  : array<string|int, mixed>
Returns the XML errors of the internal XML parser.
parseNotesMetadata()  : array<string|int, mixed>
utf8ToCharset()  : string
Convert a UTF8 string to the specified encoding.
validateSchema()  : mixed
Validates and parses the given file into a DOMDocument.

Methods

load()

Loads a locale.

public load(mixed $resource, mixed $locale[, mixed $domain = 'messages' ]) : MessageCatalogue
Parameters
$resource : mixed

A resource

$locale : mixed

A locale

$domain : mixed = 'messages'

The domain

Return values
MessageCatalogue

A MessageCatalogue instance

extractXliff1()

Extract messages and metadata from DOMDocument into a MessageCatalogue.

private extractXliff1(DOMDocument $dom, MessageCatalogue $catalogue, string $domain) : mixed
Parameters
$dom : DOMDocument

Source to extract messages and metadata

$catalogue : MessageCatalogue

Catalogue where we'll collect messages and metadata

$domain : string

The domain

Return values
mixed

fixXmlLocation()

Internally changes the URI of a dependent xsd to be loaded locally.

private fixXmlLocation(string $schemaSource, string $xmlUri) : string
Parameters
$schemaSource : string

Current content of schema file

$xmlUri : string

External URI of XML to convert to local

Return values
string

getSchema()

private getSchema(mixed $xliffVersion) : mixed
Parameters
$xliffVersion : mixed
Return values
mixed

getVersionNumber()

Gets xliff file version based on the root "version" attribute.

private getVersionNumber(DOMDocument $dom) : string

Defaults to 1.2 for backwards compatibility.

Parameters
$dom : DOMDocument
Tags
throws
InvalidArgumentException
Return values
string

getXmlErrors()

Returns the XML errors of the internal XML parser.

private getXmlErrors(bool $internalErrors) : array<string|int, mixed>
Parameters
$internalErrors : bool
Return values
array<string|int, mixed>

An array of errors

parseNotesMetadata()

private parseNotesMetadata([SimpleXMLElement $noteElement = null ][, string|null $encoding = null ]) : array<string|int, mixed>
Parameters
$noteElement : SimpleXMLElement = null
$encoding : string|null = null
Return values
array<string|int, mixed>

utf8ToCharset()

Convert a UTF8 string to the specified encoding.

private utf8ToCharset(string $content[, string $encoding = null ]) : string
Parameters
$content : string

String to decode

$encoding : string = null

Target encoding

Return values
string

validateSchema()

Validates and parses the given file into a DOMDocument.

private validateSchema(string $file, DOMDocument $dom, string $schema) : mixed
Parameters
$file : string
$dom : DOMDocument
$schema : string

source of the schema

Tags
throws
InvalidResourceException
Return values
mixed

Search results