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

Class: Translation2_Decorator

Source Location: /Translation2-2.0.0beta10/Decorator.php

Class Overview

Translation2
   |
   --Translation2_Decorator

Translation2_Decorator. Base Decorator class for Translation2


Author(s):

Copyright:

  • 2004-2005 Lorenzo Alberton

Variables

Methods


Child classes:

Translation2_Decorator_Iconv
Translation2 Iconv Decorator
Translation2_Decorator_DefaultText
Decorator to provide a fallback text for empty strings.
Translation2_Decorator_CacheMemory
Decorator to cache fetched data in memory
Translation2_Decorator_Lang
Decorator to provide a fallback language for empty strings.
Translation2_Decorator_ErrorText
Decorator to provide a fallback text for empty strings.
Translation2_Decorator_UTF8
Decorator to convert UTF-8 strings to ISO-8859-1
Translation2_Decorator_SpecialChars
Decorator to replace special chars with the matching html entities.
Translation2_Decorator_CacheLiteFunction
Decorator to cache fetched data using the Cache_Lite_Function class.
Translation2_Admin_Decorator
Decorates a Translation2_Admin class.

Inherited Variables

Inherited Methods

Class: Translation2

Translation2::Translation2()
Constructor
Translation2::factory()
Return a Translation2 instance already initialized
Translation2::get()
Get translated string
Translation2::getDecorator()
Return an instance of a decorator
Translation2::getLang()
get lang info
Translation2::getLangs()
get langs
Translation2::getPage()
Get an entire group of strings
Translation2::getRaw()
Get translated string (as-is)
Translation2::getRawPage()
Get the array of strings in a page
Translation2::getStringID()
Get the stringID for the given string. This method is the reverse of get().
Translation2::replaceEmptyStringsWithKeys()
Replace empty strings with their stringID
Translation2::setContainerOptions()
Set some storage driver options
Translation2::setLang()
Set default lang
Translation2::setPageID()
Set default page
Translation2::setParams()
Set parameters for next string
Translation2::_replaceParams()
Replace parameters in strings
Translation2::__clone()
Clone internal object references

Class Details

[line 54]
Translation2_Decorator. Base Decorator class for Translation2

Extend this class to provide custom decorators. Some decorators are already bundled with the package.



[ Top ]


Class Variables

$currentPageID =

[line 81]

  • Access: protected

Type:   string
Overrides:   Array


[ Top ]

$lang =

[line 75]

  • Access: protected

Type:   array
Overrides:   Array


[ Top ]

$storage =

[line 69]

  • Access: protected

Type:   object
Overrides:   Array


[ Top ]

$translation2 =

[line 63]

Translation2 object being decorated
  • Access: protected

Type:   object


[ Top ]



Method Detail

Translation2_Decorator (Constructor)   [line 92]

Translation2_Decorator Translation2_Decorator( object Translation2 &$translation2)

Constructor

Constructs the Translation2_Decorator


Parameters:

object Translation2   &$translation2   —  object to decorate

[ Top ]

get   [line 271]

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

Get translated string

All the filters are applied.


Overridden in child classes as:

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

Overrides Translation2::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 162]

object Decorator &getDecorator( string $decorator, object [optional] 1)

Return an instance of a decorator
  • Return: object reference
  • Access: public

Overrides Translation2::getDecorator() (Return an instance of a decorator)

Parameters:

string   $decorator   —  Name of the decorator
object [optional]   1   — 

[ Top ]

getLang   [line 206]

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

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

Overrides Translation2::getLang() (get lang info)

Parameters:

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

[ Top ]

getLangs   [line 219]

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

get langs

Overrides Translation2::getLangs() (get langs)

Parameters:

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

[ Top ]

getPage   [line 304]

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

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

Overridden in child classes as:

Translation2_Decorator_Iconv::getPage()
Same as getRawPage, but apply transformations when needed
Translation2_Decorator_DefaultText::getPage()
Replace empty strings with their $stringID
Translation2_Decorator_CacheMemory::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_Lang::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_ErrorText::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_UTF8::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_CacheLiteFunction::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed

Overrides Translation2::getPage() (Get an entire group of strings)

Parameters:

string   $pageID   — 
string   $langID   — 

[ Top ]

getRaw   [line 251]

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

Get translated string

No filter is applied.


Overridden in child classes as:

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

Overrides Translation2::getRaw() (Get translated string (as-is))

Parameters:

string   $stringID   — 
string   $pageID   — 
string   $langID   — 
string   $defaultText   —  Text to display when the strings in both the default and the fallback lang are empty

[ Top ]

getRawPage   [line 288]

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

Get the array of strings in a page

Fetch the strings from the container, without any replacing


Overridden in child classes as:

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

Overrides Translation2::getRawPage() (Get the array of strings in a page)

Parameters:

string   $pageID   — 
string   $langID   — 

[ Top ]

getStringID   [line 364]

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_DefaultText::getStringID()
Get the stringID for the given string. This method is the reverse of get().
Translation2_Decorator_CacheLiteFunction::getStringID()
Get translated string

Overrides Translation2::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 330]

void replaceEmptyStringsWithKeys( $strings, mixed $params)

Replace empty strings with their stringID
  • Access: public

Overrides Translation2::replaceEmptyStringsWithKeys() (Replace empty strings with their stringID)

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]

setContainerOptions   [line 146]

void setContainerOptions( array $options)

Set some storage driver options
  • Access: protected

Overrides Translation2::setContainerOptions() (Set some storage driver options)

Parameters:

array   $options   — 

[ Top ]

setLang   [line 180]

void setLang( string $langID)

Set default lang

Overrides Translation2::setLang() (Set default lang)

Parameters:

string   $langID   — 

[ Top ]

setOption   [line 127]

void setOption( string $option, [mixed $value = null])

set Decorator option

Overridden in child classes as:

Translation2_Decorator_Lang::setOption()
set Decorator option (intercept 'fallbackLang' option).

Parameters:

string   $option   —  option name
mixed   $value   —  option value

[ Top ]

setOptions   [line 109]

void setOptions( [array $options = array()])

set Decorator options

Parameters:

array   $options   —  options

[ Top ]

setPageID   [line 192]

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

Set default page

Overrides Translation2::setPageID() (Set default page)

Parameters:

string   $langID   — 
   $pageID   — 

[ Top ]

setParams   [line 231]

void setParams( [array $params = null])

Set parameters for next string

Overrides Translation2::setParams() (Set parameters for next string)

Parameters:

array   $params   — 

[ Top ]

translate   [line 347]

string translate( string $string, string $langID, [ $pageID = TRANSLATION2_DEFAULT_PAGEID])

Get translated string

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   $langID   — 
   $pageID   — 

[ Top ]

_replaceParams   [line 317]

void _replaceParams( $strings, mixed $params)

Replace parameters in strings
  • Access: protected

Overrides Translation2::_replaceParams() (Replace parameters in strings)

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]

__clone   [line 379]

void __clone( )

Clone internal object references

This method is called automatically by PHP5

  • Access: protected

Overrides Translation2::__clone() (Clone internal object references)
[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:41:44 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.