PHP Class Prado\I18N\core\MessageSource_gettext

Using Gettext MO format as the message source for translation. The gettext classes are based on PEAR's gettext MO and PO classes. See the MessageSource::factory() method to instantiate this class.
Inheritance: extends MessageSource
Datei anzeigen Open project: pradosoft/prado

Protected Properties

Property Type Description
$dataExt string Message data filename extension.
$dataSeparator string Separator between culture name and source.
$poExt string PO data filename extension

Public Methods

Method Description
__construct ( $source )
catalogues ( ) : array Returns a list of catalogue as key and all it variants as value.
delete ( $message, $catalogue = 'messages' ) : boolean Delete a particular message from the specified catalogue.
save ( $catalogue = 'messages' ) : boolean Save the list of untranslated blocks to the translation source.
update ( $text, $target, $comments, $catalogue = 'messages' ) : boolean Update the translation.

Protected Methods

Method Description
createMessageTemplate ( $catalogue )
getCatalogueList ( $catalogue ) : array Get all the variants of a particular catalogue.
getCatalogues ( $dir = null, $variant = null ) : array Returns a list of catalogue and its culture ID. This takes care of directory structures.
getLastModified ( $source ) : integer Get the last modified unix-time for this particular catalogue+variant.
getSource ( $variant ) : string Get the MO file for a specific message catalogue and cultural vairant.
isValidSource ( $filename ) : boolean Determin if the MO file source is valid.
loadData ( $filename ) : array Load the messages from a MO file.

Private Methods

Method Description
getCatalogueByDir ( $catalogue ) : array Traverse through the directory structure to find the catalogues.
getPOFile ( $MOFile )
getVariants ( $catalogue = 'messages' ) : string Get the variant for a catalogue depending on the current culture.

Method Details

__construct() public method

public __construct ( $source )

catalogues() public method

Returns a list of catalogue as key and all it variants as value.
public catalogues ( ) : array
return array list of catalogues

createMessageTemplate() protected method

protected createMessageTemplate ( $catalogue )

delete() public method

Delete a particular message from the specified catalogue.
public delete ( $message, $catalogue = 'messages' ) : boolean
return boolean true if deleted, false otherwise.

getCatalogueList() protected method

Get all the variants of a particular catalogue.
protected getCatalogueList ( $catalogue ) : array
return array list of all variants for this catalogue.

getCatalogues() protected method

E.g. array('messages','en_AU')
protected getCatalogues ( $dir = null, $variant = null ) : array
return array list of catalogues

getLastModified() protected method

Just use the file modified time.
protected getLastModified ( $source ) : integer
return integer last modified in unix-time format.

getSource() protected method

Get the MO file for a specific message catalogue and cultural vairant.
protected getSource ( $variant ) : string
return string full path to the MO file.

isValidSource() protected method

Determin if the MO file source is valid.
protected isValidSource ( $filename ) : boolean
return boolean true if valid, false otherwise.

loadData() protected method

Load the messages from a MO file.
protected loadData ( $filename ) : array
return array of messages.

save() public method

If the translation was not found, you should add those strings to the translation source via the append() method.
public save ( $catalogue = 'messages' ) : boolean
return boolean true if saved successfuly, false otherwise.

update() public method

Update the translation.
public update ( $text, $target, $comments, $catalogue = 'messages' ) : boolean
return boolean true if translation was updated, false otherwise.

Property Details

$dataExt protected_oe property

Message data filename extension.
protected string $dataExt
return string

$dataSeparator protected_oe property

Separator between culture name and source.
protected string $dataSeparator
return string

$poExt protected_oe property

PO data filename extension
protected string $poExt
return string