MoFileLoader
extends FileLoader
in package
ArrayLoader loads translations from a PHP array.
Tags
Table of Contents
Constants
- MO_BIG_ENDIAN_MAGIC = 0xde120495
- Magic used for validating the format of an MO file as well as detecting if the machine used to create that file was big endian.
- MO_HEADER_SIZE = 28
- The size of the header of an MO file in bytes.
- MO_LITTLE_ENDIAN_MAGIC = 0x950412de
- Magic used for validating the format of an MO file as well as detecting if the machine used to create that file was little endian.
Methods
- load() : MessageCatalogue
- Loads a locale.
- loadResource() : array<string|int, mixed>
- Parses machine object (MO) format, independent of the machine's endian it was created on. Both 32bit and 64bit systems are supported.
- flatten() : array<string|int, mixed>
- Flattens an nested array of translations.
- readLong() : int
- Reads an unsigned long from stream respecting endianness.
Constants
MO_BIG_ENDIAN_MAGIC
Magic used for validating the format of an MO file as well as detecting if the machine used to create that file was big endian.
public
mixed
MO_BIG_ENDIAN_MAGIC
= 0xde120495
MO_HEADER_SIZE
The size of the header of an MO file in bytes.
public
mixed
MO_HEADER_SIZE
= 28
MO_LITTLE_ENDIAN_MAGIC
Magic used for validating the format of an MO file as well as detecting if the machine used to create that file was little endian.
public
mixed
MO_LITTLE_ENDIAN_MAGIC
= 0x950412de
Methods
load()
Loads a locale.
public
load(mixed $resource, string $locale[, string $domain = 'messages' ]) : MessageCatalogue
Parameters
- $resource : mixed
- $locale : string
- $domain : string = 'messages'
Return values
MessageCatalogueloadResource()
Parses machine object (MO) format, independent of the machine's endian it was created on. Both 32bit and 64bit systems are supported.
protected
loadResource(string $resource) : array<string|int, mixed>
Parameters
- $resource : string
Return values
array<string|int, mixed>flatten()
Flattens an nested array of translations.
private
flatten(array<string|int, mixed> $messages) : array<string|int, mixed>
The scheme used is: 'key' => ['key2' => ['key3' => 'value']] Becomes: 'key.key2.key3' => 'value'
Parameters
- $messages : array<string|int, mixed>
Return values
array<string|int, mixed>readLong()
Reads an unsigned long from stream respecting endianness.
private
readLong(resource $stream, bool $isBigEndian) : int
Parameters
- $stream : resource
- $isBigEndian : bool