GettextPoFile
API reference › yii › i18n › GettextPoFile
GettextPoFile represents a PO Gettext message file.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$behaviors read-only | array<yii\<static>> | List of behaviors attached to this component. | yii\ |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__clone() | This method is called after the object is created by cloning an existing one. | yii\ |
__get() | Returns the value of a component property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets the value of a component property. | yii\ |
__unset() | Sets a component property to be null. | yii\ |
attachBehavior() | Attaches a behavior to this component. | yii\ |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\ |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
detachBehavior() | Detaches a behavior from the component. | yii\ |
detachBehaviors() | Detaches all behaviors from the component. | yii\ |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\ |
getBehavior() | Returns the named behavior object. | yii\ |
getBehaviors() | Returns all behaviors attached to this component. | yii\ |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\ |
init() | Initializes the object. | yii\ |
load() | Loads messages from a PO file. | GettextPoFile |
off() | Detaches an existing event handler from this component. | yii\ |
on() | Attaches an event handler to an event. | yii\ |
save() | Saves messages to a PO file. | GettextPoFile |
trigger() | Triggers an event. | yii\ |
decode() protected | Decodes special characters in a message. | GettextPoFile |
encode() protected | Encodes special characters in a message. | GettextPoFile |
Method details
Section titled “Method details”load()
Section titled “load() ”public function load(string $filePath, string $context): arrayLoads messages from a PO file.
Parameters
| Parameter | Type | Description |
|---|---|---|
$filePath | string | File path |
$context | string | Message context |
Returns
array: Message translations. Array keys are source messages and array values are translated messages: source message => translated message.
save()
Section titled “save() ”public function save(string $filePath, array $messages): mixedSaves messages to a PO file.
Parameters
| Parameter | Type | Description |
|---|---|---|
$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. |
Returns
mixed
decode()
Section titled “decode() ”protected function decode(string $string): stringDecodes special characters in a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
$string | string | Message to be decoded |
Returns
string: The decoded message
encode()
Section titled “encode() ”protected function encode(string $string): stringEncodes special characters in a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
$string | string | Message to be encoded |
Returns
string: The encoded message