Class yii\i18n\GettextMoFile

继承yii\i18n\GettextMoFile » yii\i18n\GettextFile » yii\base\Component » yii\base\BaseObject
实现yii\base\Configurable
可用自版本2.0
源代码 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.

公共属性

隐藏继承的属性

属性类型描述定义在
$behaviors yii\base\Behavior[] 附加到此组件的行为列表. 该属性是只读的. yii\base\Component
$useBigEndian boolean Whether to use big-endian when reading and writing an integer. yii\i18n\GettextMoFile

公共方法

隐藏继承的方法

方法描述定义在
__call() 调用不是类方法的指定的方法. yii\base\Component
__clone() 在通过克隆现有对象创建对象之后调用此方法. yii\base\Component
__construct() 构造函数. yii\base\BaseObject
__get() 返回组件属性的值. yii\base\Component
__isset() 检查属性是否已设置, 即已定义且不为null. yii\base\Component
__set() 设置组件属性的值. yii\base\Component
__unset() 将组件属性设置为null. yii\base\Component
attachBehavior() 将行为附加到此组件. yii\base\Component
attachBehaviors() 将行为列表附加到组件. yii\base\Component
behaviors() 返回此组件应该具有的行为列表. yii\base\Component
canGetProperty() 返回一个值, 指示属性是否可读取. yii\base\Component
canSetProperty() 返回一个值, 指示属性是否可设置. yii\base\Component
className() 返回此类的完全限定名称. yii\base\BaseObject
detachBehavior() 从组件中分离一个行为. yii\base\Component
detachBehaviors() 分离组件中的所有行为. yii\base\Component
ensureBehaviors() 确保在 behaviors() 中声明的行为已附加到此组件. yii\base\Component
getBehavior() 返回指定的行为对象. yii\base\Component
getBehaviors() 返回附加到此组件的所有行为. yii\base\Component
hasEventHandlers() 返回一个值, 指示是否有任何处理程序附加到指定的事件. yii\base\Component
hasMethod() 返回一个值, 指示方法是否已定义. yii\base\Component
hasProperty() 返回一个值, 指示属性是否已定义. yii\base\Component
init() 初始化对象. yii\base\BaseObject
load() Loads messages from an MO file. yii\i18n\GettextMoFile
off() 从该组件分离现有的事件处理程序. yii\base\Component
on() 将事件处理程序附加到事件. yii\base\Component
save() Saves messages to an MO file. yii\i18n\GettextMoFile
trigger() 触发事件. yii\base\Component

受保护的方法

隐藏继承的方法

方法描述定义在
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

属性详情

$useBigEndian public 属性

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

public boolean $useBigEndian false

方法详情

load() public 方法

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 方法

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 方法

Reads a 4-byte integer.

protected integer readInteger ( $fileHandle )
$fileHandle resource

To read from

return integer

The result

readString() protected 方法

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 方法

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 方法

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 方法

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 方法

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