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

Class: Translation2

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

Class Overview


Translation2 class


Variables

Methods


Child classes:

Translation2_Admin
Administration utilities for translation string management

Inherited Variables

Inherited Methods


Class Details

[line 57]
Translation2 class


[ Top ]


Class Variables

$currentPageID =  null

[line 83]

Current pageID

Type:   string


[ Top ]

$lang = array()

[line 77]

Default lang

Type:   array


[ Top ]

$options = array()

[line 71]

Class options

Type:   array


[ Top ]

$params = array()

[line 89]

Array parameters

Type:   array


[ Top ]

$storage =  ''

[line 65]

Storage object

Type:   object


[ Top ]



Method Detail

Translation2 (Constructor)   [line 97]

Translation2 Translation2( )

Constructor

[ Top ]

factory   [line 123]

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

Return a Translation2 instance already initialized
  • Return: instance or PEAR_Error on failure
  • Access: public

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)
   $driver   — 

[ Top ]

get   [line 401]

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.


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 ]

getDecorator   [line 211]

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
  • Access: public

Parameters:

string   $decorator   —  Name of the decorator

[ Top ]

getLang   [line 272]

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

Parameters:

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

[ Top ]

getLangs   [line 301]

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

get langs

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


Parameters:

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

[ Top ]

getPage   [line 443]

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

Get an entire group of strings

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


Parameters:

string   $pageID   — 
string   $langID   — 
   $defaultText   — 

[ Top ]

getRawPage   [line 424]

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


Parameters:

string   $pageID   — 
string   $langID   — 

[ Top ]

getStringID   [line 461]

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

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 370]

void replaceEmptyStringsWithKeys( $strings, mixed $params)

Replace empty strings with their stringID
  • Access: public

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]

setLang   [line 234]

void setLang( string $langID)

Set default lang

Set the language that shall be used when retrieving strings.


Parameters:

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

[ Top ]

setPageID   [line 254]

void setPageID( [ $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.


Parameters:

string   $langID   — 
   $pageID   — 

[ Top ]

setParams   [line 317]

void setParams( [array $params = null])

Set parameters for next string

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


Parameters:

array   $params   — 

[ Top ]

_replaceParams   [line 336]

void _replaceParams( $strings, mixed $params)

Replace parameters in strings
  • Access: protected

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:58:52 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.