Translation2
[ class tree: Translation2 ] [ index: Translation2 ] [ all elements ]

Class: Translation2

Source Location: /Translation2-2.0.0beta8/Translation2.php

Class Overview


Translation2 base class


Author(s):

Copyright:

  • 2004-2005 Lorenzo Alberton

Variables

Methods


Child classes:

Translation2_Admin
Administration utilities for translation string management
Translation2_Decorator
Translation2_Decorator. Base Decorator class for Translation2

Inherited Variables

Inherited Methods


Class Details

[line 80]
Translation2 base class

This class provides an easy way to retrieve all the strings for a multilingual site or application from a data source (i.e. a db, an xml file or a gettext file).



[ Top ]


Class Variables

$currentPageID =  null

[line 109]

Current pageID
  • Access: protected

Type:   string


[ Top ]

$lang = array()

[line 102]

Default lang
  • Access: protected

Type:   array


[ Top ]

$options = array()

[line 95]

Class options

Type:   array


[ Top ]

$params = array()

[line 116]

Array parameters
  • Access: protected

Type:   array


[ Top ]

$storage =  ''

[line 89]

Storage object
  • Access: protected

Type:   object


[ Top ]



Method Detail

Translation2 (Constructor)   [line 124]

Translation2 Translation2( )

Constructor

[ Top ]

factory   [line 149]

object Translation2 &factory( mixed $driver, [mixed $options = ''], [array $params = array()], string $storageDriver)

Return a Translation2 instance already initialized
  • Return: instance or PEAR_Error on failure
  • Static: This method can be called statically

Overridden in child classes as:

Translation2_Admin::factory()
Return a Translation2_Admin instance already initialized

Parameters:

string   $storageDriver     Type of the storage driver
mixed   $options     Additional options for the storage driver (example: if you are using DB as the storage driver, you have to pass the dsn string here)
array   $params     Array of parameters for the adapter class (i.e. you can set here the mappings between your table/field names and the ones used by this class)

[ Top ]

get   [line 469]

string get( string $stringID, [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null], [string $defaultText = ''])

Get translated string

First check if the string is cached, if not => fetch the page from the container and cache it for later use. If the string is empty, check the fallback language; if the latter is empty too, then return the $defaultText.


Overridden in child classes as:

Translation2_Decorator::get()
Get translated string
Translation2_Admin_Decorator_Autoadd::get()
Get a translated string
Translation2_Decorator_CacheLiteFunction::get()
Get translated string
Translation2_Decorator_CacheMemory::get()
Get translated string
Translation2_Decorator_DefaultText::get()
Get translated string
Translation2_Decorator_ErrorText::get()
Get translated string
Translation2_Decorator_Iconv::get()
Get the translated string, in the new encoding
Translation2_Decorator_Lang::get()
Get translated string
Translation2_Decorator_SpecialChars::get()
Get translated string
Translation2_Decorator_UTF8::get()
Get translated string

Parameters:

string   $stringID     
string   $pageID     
string   $langID     
string   $defaultText     Text to display when the string is empty NB: This parameter is only used in the DefaultText decorator

[ Top ]

getDecorator   [line 251]

object Decorator &getDecorator( string $decorator)

Return an instance of a decorator

This method is used to get a decorator instance. A decorator can be seen as a filter, i.e. something that can change or handle the values of the objects/vars that pass through.

  • Return: object reference

Overridden in child classes as:

Translation2_Decorator::getDecorator()
Return an instance of a decorator

Parameters:

string   $decorator     Name of the decorator

[ Top ]

getLang   [line 313]

mixed getLang( [string $langID = null], [string $format = 'name'])

get lang info

Get some extra information about the language (its full name, the localized error text, ...)

  • Return: [string | array], depending on $format

Overridden in child classes as:

Translation2_Decorator::getLang()
get lang info

Parameters:

string   $langID     
string   $format     ['name', 'meta', 'error_text', 'array']

[ Top ]

getLangs   [line 348]

array getLangs( [string $format = 'name'])

get langs

Get some extra information about the languages (their full names, the localized error text, their codes, ...)


Overridden in child classes as:

Translation2_Decorator::getLangs()
get langs

Parameters:

string   $format     ['ids', 'names', 'array']

[ Top ]

getPage   [line 510]

array getPage( [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null])

Get an entire group of strings

Same as getRawPage, but resort to fallback language and replace parameters when needed


Overridden in child classes as:

Translation2_Decorator::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_CacheLiteFunction::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_CacheMemory::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_DefaultText::getPage()
Replace empty strings with their $stringID
Translation2_Decorator_ErrorText::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_Iconv::getPage()
Same as getRawPage, but apply transformations when needed
Translation2_Decorator_Lang::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_SpecialChars::getPage()
Same as getRawPage, but apply transformations when needed
Translation2_Decorator_UTF8::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed

Parameters:

string   $pageID     
string   $langID     

[ Top ]

getRaw   [line 441]

string|PEAR_Error getRaw( string $stringID, [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null], [string $defaultText = ''])

Get translated string (as-is)

Overridden in child classes as:

Translation2_Decorator::getRaw()
Get translated string
Translation2_Decorator_CacheLiteFunction::getRaw()
Get translated string (as-is)
Translation2_Decorator_CacheMemory::getRaw()
Get translated string (as-is)

Parameters:

string   $stringID     
string   $pageID     
string   $langID     
string   $defaultText     Text to display when the string is empty

[ Top ]

getRawPage   [line 491]

array getRawPage( [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null])

Get the array of strings in a page

Fetch the page (aka "group of strings) from the container, without applying any formatting and without replacing the parameters


Overridden in child classes as:

Translation2_Decorator::getRawPage()
Get the array of strings in a page
Translation2_Decorator_CacheLiteFunction::getRawPage()
Get the array of strings in a page
Translation2_Decorator_CacheMemory::getRawPage()
Get the array of strings in a page

Parameters:

string   $pageID     
string   $langID     

[ Top ]

getStringID   [line 528]

string getStringID( string $string, [string $pageID = TRANSLATION2_DEFAULT_PAGEID])

Get the stringID for the given string. This method is the reverse of get().

Overridden in child classes as:

Translation2_Decorator::getStringID()
Get the stringID for the given string. This method is the reverse of get().
Translation2_Decorator_CacheLiteFunction::getStringID()
Get translated string
Translation2_Decorator_DefaultText::getStringID()
Get the stringID for the given string. This method is the reverse of get().

Parameters:

string   $string     This is NOT the stringID, this is a real string. The method will search for its matching stringID, and then it will return the associate string in the selected language.
string   $pageID     

[ Top ]

replaceEmptyStringsWithKeys   [line 416]

void replaceEmptyStringsWithKeys( mixed $strings, mixed $params)

Replace empty strings with their stringID
  • Static: This method can be called statically

Overridden in child classes as:

Translation2_Decorator::replaceEmptyStringsWithKeys()
Replace empty strings with their stringID

Parameters:

mixed   $params     

[ Top ]

setContainerOptions   [line 198]

void setContainerOptions( array $options)

Set some storage driver options
  • Access: protected

Overridden in child classes as:

Translation2_Decorator::setContainerOptions()
Set some storage driver options

Parameters:

array   $options     

[ Top ]

setLang   [line 275]

void setLang( string $langID)

Set default lang

Set the language that shall be used when retrieving strings.


Overridden in child classes as:

Translation2_Decorator::setLang()
Set default lang

Parameters:

string   $langID     language code (for instance, 'en' or 'it')

[ Top ]

setPageID   [line 295]

void setPageID( [mixed $pageID = null], string $langID)

Set default page

Set the page (aka "group of strings") that shall be used when retrieving strings. If you set it, you don't have to state it in each get() call.


Overridden in child classes as:

Translation2_Decorator::setPageID()
Set default page

Parameters:

string   $langID     

[ Top ]

setParams   [line 364]

void setParams( [array $params = null])

Set parameters for next string

Set the replacement for the parameters in the string(s). Parameter delimiters are customizable.


Overridden in child classes as:

Translation2_Decorator::setParams()
Set parameters for next string

Parameters:

array   $params     

[ Top ]

_replaceParams   [line 383]

void _replaceParams( mixed $strings, mixed $params)

Replace parameters in strings
  • Access: protected

Overridden in child classes as:

Translation2_Decorator::_replaceParams()
Replace parameters in strings

Parameters:

mixed   $params     

[ Top ]

__clone   [line 544]

void __clone( )

Clone internal object references

This method is called automatically by PHP5

  • Access: protected

Overridden in child classes as:

Translation2_Decorator::__clone()
Clone internal object references

[ Top ]


Documentation generated on Sun, 09 Oct 2005 06:32:24 -0400 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.