W3cubDocs

/Yii 2.0

Class yii\i18n\GettextMoFile

Inheritance yii\i18n\GettextMoFile » yii\i18n\GettextFile » yii\base\Component » yii\base\Object
Implements yii\base\Configurable
Available since version 2.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 [email protected]. 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

Property Type Description Defined 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

Method Description Defined 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\Object
__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\Object
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\Object
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

Method Description Defined 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

© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-i18n-gettextmofile.html