System.I18N.core
[ class tree: System.I18N.core ] [ index: System.I18N.core ] [ all elements ]

Class: MessageSource_gettext

Source Location: /I18N/core/MessageSource_gettext.php

Class Overview

MessageSource
   |
   --MessageSource_gettext

MessageSource_gettext class.

Class Details

[line 42]
MessageSource_gettext class.

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.




version:  v1.0, last update on Fri Dec 24 16:18:44 EST 2004
author:  Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>


[ Top ]

Variables

Methods


Inherited Variables

Inherited Methods

Class: MessageSource

MessageSource::append()
Add a untranslated message to the source. Need to call save() to save the messages to source.
MessageSource::factory()
Factory method to instantiate a new MessageSource depending on the
MessageSource::getCache()
Get the cache handler for this source.
MessageSource::getCatalogueList()
Get all the variants of a particular catalogue.
MessageSource::getCulture()
Get the culture identifier for the source.
MessageSource::getLastModified()
Get the last modified unix-time for this particular catalogue+variant.
MessageSource::getSource()
Get the source, this could be a filename or database ID.
MessageSource::isValidSource()
Determine if the source is valid.
MessageSource::load()
Load a particular message catalogue. Use read() to to get the array of messages. The catalogue loading sequence is as follows
MessageSource::loadData()
Load the message for a particular catalogue+variant.
MessageSource::read()
Get the array of messages.
MessageSource::setCache()
Set the cache handler for caching the messages.
MessageSource::setCulture()
Set the culture for this message source.

Class Variables

$dataExt =  '.mo'

[line 48]

Message data filename extension.



access:  protected

Type:   string


[ Top ]

$dataSeparator =  '.'

[line 60]

Separator between culture name and source.



access:  protected

Type:   string


[ Top ]

$poExt =  '.po'

[line 54]

PO data filename extension



access:  protected

Type:   string


[ Top ]



Class Methods


constructor __construct [line 62]

MessageSource_gettext __construct( mixed $source)



[ Top ]

method catalogues [line 365]

array catalogues( )

Returns a list of catalogue as key and all it variants as value.



return:  list of catalogues


[ Top ]

method delete [line 274]

boolean delete( string $message, [string $catalogue = 'messages'])

Delete a particular message from the specified catalogue.



return:  true if deleted, false otherwise.


Parameters:

string   $message   the source message to delete.
string   $catalogue   the catalogue to delete from.

[ Top ]

method getCatalogueList [line 130]

array getCatalogueList( string $catalogue)

Get all the variants of a particular catalogue.



return:  list of all variants for this catalogue.
access:  protected


Overrides MessageSource::getCatalogueList() (Get all the variants of a particular catalogue.)

Parameters:

string   $catalogue   catalogue name

[ Top ]

method getCatalogues [line 376]

array getCatalogues( [mixed $dir = null], [mixed $variant = null])

Returns a list of catalogue and its culture ID. This takes care of directory structures.

E.g. array('messages','en_AU')




return:  list of catalogues
access:  protected


[ Top ]

method getLastModified [line 117]

int getLastModified( string $source)

Get the last modified unix-time for this particular catalogue+variant.

Just use the file modified time.




return:  last modified in unix-time format.
access:  protected


Overrides MessageSource::getLastModified() (Get the last modified unix-time for this particular catalogue+variant.)

Parameters:

string   $source   catalogue+variant

[ Top ]

method getSource [line 106]

string getSource( string $variant)

Get the MO file for a specific message catalogue and cultural vairant.



return:  full path to the MO file.
access:  protected


Overrides MessageSource::getSource() (Get the source, this could be a filename or database ID.)

Parameters:

string   $variant   message catalogue

[ Top ]

method isValidSource [line 95]

boolean isValidSource( string $filename)

Determin if the MO file source is valid.



return:  true if valid, false otherwise.
access:  protected


Overrides MessageSource::isValidSource() (Determine if the source is valid.)

Parameters:

string   $filename   MO file

[ Top ]

method loadData [line 73]

array &loadData( string $filename)

Load the messages from a MO file.



return:  of messages.
access:  protected


Overrides MessageSource::loadData() (Load the message for a particular catalogue+variant.)

Parameters:

string   $filename   MO file.

[ Top ]

method save [line 215]

boolean save( [string $catalogue = 'messages'])

Save the list of untranslated blocks to the translation source.

If the translation was not found, you should add those strings to the translation source via the append() method.




return:  true if saved successfuly, false otherwise.


Parameters:

string   $catalogue   the catalogue to add to

[ Top ]

method update [line 320]

boolean update( string $text, string $target, string $comments, [string $catalogue = 'messages'])

Update the translation.



return:  true if translation was updated, false otherwise.


Parameters:

string   $text   the source string.
string   $target   the new translation string.
string   $comments   comments
string   $catalogue   the catalogue of the translation.

[ Top ]


© 2004-2005 PRADO Software Group. All Rights Reserved.