Class yii\i18n\GettextMoFile
GettextMoFile 表示 MO Gettext 消息文件。
这个类是通过在 PEAR 中调整 Michael 的 Gettext_MO 类来编写的。 请参阅以下许可条款。
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[] | List of behaviors attached to this component | yii\base\Component |
$useBigEndian | boolean | 在读写整数时是否使用 big-endian。 | yii\i18n\GettextMoFile |
公共方法
方法 | 描述 | 被定义在 |
---|---|---|
__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() | 从 MO 文件加载消息。 | 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() | 将消息保存到 MO 文件。 | yii\i18n\GettextMoFile |
trigger() | Triggers an event. | yii\base\Component |
受保护的方法
方法 | 描述 | 被定义在 |
---|---|---|
readBytes() | 读一个或多个字节。 | yii\i18n\GettextMoFile |
readInteger() | 读一个 4 字节的整数。 | yii\i18n\GettextMoFile |
readString() | 读入一个字符串 | yii\i18n\GettextMoFile |
writeBytes() | 写入字节。 | yii\i18n\GettextMoFile |
writeInteger() | 写一个 4 字节的整数。 | yii\i18n\GettextMoFile |
writeString() | 写一个字符串。 | yii\i18n\GettextMoFile |
属性详情
方法详情
从 MO 文件加载消息。
public array load($filePath, $context) | ||
$filePath | string | 文件路径 |
$context | string | 消息上下文 |
return | array | 消息翻译。 数组键是源消息,数组值是已翻译的消息: 源消息 => 已翻译的消息。 |
---|---|---|
throws | yii\base\Exception | 如果无法读取 MO 文件 |
读一个或多个字节。
protected string readBytes($fileHandle, $byteCount = 1) | ||
$fileHandle | resource | 要读入的文件句柄 |
$byteCount | integer | 要读入的字节数目 |
return | string | 字节 |
---|
读一个 4 字节的整数。
protected integer readInteger($fileHandle) | ||
$fileHandle | resource | 要读入的文件句柄 |
return | integer | 结果 |
---|
读入一个字符串
protected string readString($fileHandle, $length, $offset = null) | ||
$fileHandle | resource | 文件句柄 |
$length | integer | 字符串的长度 |
$offset | integer | 文件中字符串的偏移量。 如果为 null,则从当前位置读取。 |
return | string | 结果 |
---|
将消息保存到 MO 文件。
public void save($filePath, $messages) | ||
$filePath | string | 文件路径 |
$messages | array | 消息翻译。 数组键是源消息,数组值是已翻译的消息:源消息 => 已翻译的消息。 请注意,如果消息具有上下文, 则消息 ID 必须以 chr(4) 作为分隔符的上下文前缀。 |
throws | yii\base\Exception | 如果无法保存 MO 文件 |
---|
写入字节。
protected integer writeBytes($fileHandle, $bytes) | ||
$fileHandle | resource | 要写入的文件句柄 |
$bytes | string | 要写入的字节 |
return | integer | 写入的字节数目 |
---|
写一个 4 字节的整数。
protected integer writeInteger($fileHandle, $integer) | ||
$fileHandle | resource | 要写入的文件句柄 |
$integer | integer | 要写入的整数 |
return | integer | 写入的字节数目 |
---|
写一个字符串。
protected integer writeString($fileHandle, $string) | ||
$fileHandle | resource | 要写入的文件句柄 |
$string | string | 要写入的字符串 |
return | integer | 写入的字节数目 |
---|