0 follower

Class yii\i18n\GettextMoFile

Inheritanceyii\i18n\GettextMoFile » yii\i18n\GettextFile » yii\base\Component » yii\base\BaseObject
Implementsyii\base\Configurable
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/i18n/GettextMoFile.php

GettextMoFile represents an MO Gettext message file.

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 mike@iworks.at. 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.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$behaviors yii\base\Behavior[] List of behaviors attached to this component yii\base\Component
$useBigEndian boolean Whether to use big-endian when reading and writing an integer. yii\i18n\GettextMoFile

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\base\BaseObject
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\BaseObject
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Initializes the object. yii\base\BaseObject
load() Loads messages from an MO file. yii\i18n\GettextMoFile
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
save() Saves messages to an MO file. yii\i18n\GettextMoFile
trigger() Triggers an event. yii\base\Component

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
readBytes() Reads one or several bytes. yii\i18n\GettextMoFile
readInteger() Reads a 4-byte integer. yii\i18n\GettextMoFile
readString() Reads a string. yii\i18n\GettextMoFile
writeBytes() Write bytes. yii\i18n\GettextMoFile
writeInteger() Writes a 4-byte integer. yii\i18n\GettextMoFile
writeString() Writes a string. yii\i18n\GettextMoFile

Property Details

$useBigEndian public property

Whether to use big-endian when reading and writing an integer.

public boolean $useBigEndian false

Method Details

load() public method

Loads messages from an MO file.

public array load ( $filePath, $context )
$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.

throws yii\base\Exception

if unable to read the MO file

readBytes() protected method

Reads one or several bytes.

protected string readBytes ( $fileHandle, $byteCount 1 )
$fileHandle resource

To read from

$byteCount integer

To be read

return string

Bytes

readInteger() protected method

Reads a 4-byte integer.

protected integer readInteger ( $fileHandle )
$fileHandle resource

To read from

return integer

The result

readString() protected method

Reads a string.

protected string readString ( $fileHandle, $length, $offset null )
$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 void save ( $filePath, $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.

throws yii\base\Exception

if unable to save the MO file

writeBytes() protected method

Write bytes.

protected integer writeBytes ( $fileHandle, $bytes )
$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 integer writeInteger ( $fileHandle, $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 integer writeString ( $fileHandle, $string )
$fileHandle resource

To write to

$string string

To be written

return integer

How many bytes are written