PHP Class yii\i18n\GettextMoFile

This class is written by adapting Michael's Gettext_MO class in PEAR. Please refer to the following license terms. Copyright (c) 2004-2005, Michael Wallner . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\i18n\GettextFile
Datei anzeigen Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$useBigEndian whether to use big-endian when reading and writing an integer.

Public Methods

Method Description
load ( string $filePath, string $context ) : array Loads messages from an MO file.
save ( string $filePath, array $messages ) Saves messages to an MO file.

Protected Methods

Method Description
readBytes ( resource $fileHandle, integer $byteCount = 1 ) : string Reads one or several bytes.
readInteger ( resource $fileHandle ) : integer Reads a 4-byte integer.
readString ( resource $fileHandle, integer $length, integer $offset = null ) : string Reads a string.
writeBytes ( resource $fileHandle, string $bytes ) : integer Write bytes.
writeInteger ( resource $fileHandle, integer $integer ) : integer Writes a 4-byte integer.
writeString ( resource $fileHandle, string $string ) : integer Writes a string.

Method Details

load() public method

Loads messages from an MO file.
public load ( string $filePath, string $context ) : array
$filePath string file path
$context string message context
return array message translations. Array keys are source messages and array values are translated messages: source message => translated message.

readBytes() protected method

Reads one or several bytes.
protected readBytes ( resource $fileHandle, integer $byteCount = 1 ) : string
$fileHandle resource to read from
$byteCount integer to be read
return string bytes

readInteger() protected method

Reads a 4-byte integer.
protected readInteger ( resource $fileHandle ) : integer
$fileHandle resource to read from
return integer the result

readString() protected method

Reads a string.
protected readString ( resource $fileHandle, integer $length, integer $offset = null ) : string
$fileHandle resource file handle
$length integer of the string
$offset integer of the string in the file. If null, it reads from the current position.
return string the result

save() public method

Saves messages to an MO file.
public save ( string $filePath, array $messages )
$filePath string file path
$messages array message translations. Array keys are source messages and array values are translated messages: source message => translated message. Note if the message has a context, the message ID must be prefixed with the context with chr(4) as the separator.

writeBytes() protected method

Write bytes.
protected writeBytes ( resource $fileHandle, string $bytes ) : integer
$fileHandle resource to write to
$bytes string to be written
return integer how many bytes are written

writeInteger() protected method

Writes a 4-byte integer.
protected writeInteger ( resource $fileHandle, integer $integer ) : integer
$fileHandle resource to write to
$integer integer to be written
return integer how many bytes are written

writeString() protected method

Writes a string.
protected writeString ( resource $fileHandle, string $string ) : integer
$fileHandle resource to write to
$string string to be written
return integer how many bytes are written

Property Details

$useBigEndian public_oe property

whether to use big-endian when reading and writing an integer.
public $useBigEndian