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

Class: Translation2_Admin

Source Location: /Translation2-2.0.4/Translation2/Admin.php

Class Overview

Translation2
   |
   --Translation2_Admin

Administration utilities for translation string management


Author(s):

Copyright:

  • 2004-2005 Lorenzo Alberton

Methods


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::setCharset()
Set charset used to read/store the translations
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 57]
Administration utilities for translation string management

Set of methods to easily add/remove languages and strings, with a common API for all the containers.



[ Top ]


Method Detail

add   [line 261]

mixed add( string $stringID, string $pageID, array $stringArray)

Add a new translation
  • Return: true on success, PEAR_Error on failure

Parameters:

string   $stringID   —  string ID
string   $pageID   —  page/group ID
array   $stringArray   —  Associative array with string translations. Sample format: array('en' => 'sample', 'it' => 'esempio')

[ Top ]

addLang   [line 182]

mixed addLang( array $langData, [array $options = array()])

Prepare the storage container for a new lang.

If the langsAvail table doesn't exist yet, it is created.

  • Return: true on success, PEAR_Error on failure

Parameters:

array   $langData   —  array('lang_id' => 'en', 'table_name' => 'i18n', 'name' => 'english', 'meta' => 'some meta info', 'error_text' => 'not available');
array   $options   —  array('charset' => 'utf8', 'collation' => 'utf8_general_ci');

[ Top ]

cleanCache   [line 354]

void cleanCache( )

If you use the CacheLiteFunction decorator, you may want to invalidate the cache after a change in the data base.

[ Top ]

factory   [line 79]

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

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

Overrides Translation2::factory() (Return a Translation2 instance already initialized)

Parameters:

string   $driver   —  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 ]

getAdminDecorator   [line 151]

object Decorator &getAdminDecorator( string $decorator)

Return an instance of an admin decorator

Parameters:

string   $decorator   —  Name of the decorator

[ Top ]

getPageNames   [line 340]

array getPageNames( )

Get a list of all the pageIDs in any table.

[ Top ]

remove   [line 304]

mixed remove( string $stringID, [string $pageID = null])

Remove a translated string
  • Return: true on success, PEAR_Error on failure
  • Todo: add a third $langs option, to conditionally remove only the langs specified

Parameters:

string   $stringID   —  string ID
string   $pageID   —  page/group ID

[ Top ]

removeLang   [line 213]

mixed removeLang( [string $langID = null], [boolean $force = false])

Remove the lang from the langsAvail table and drop the strings table.

If the strings table holds other langs and $force==false, then only the lang column is dropped. If $force==true the whole table is dropped without any check

  • Return: true on success, PEAR_Error on failure

Parameters:

string   $langID   —  language ID
boolean   $force   —  remove the language info without further checks

[ Top ]

removePage   [line 323]

mixed removePage( [string $pageID = null])

Remove all the strings in the given page/group
  • Return: true on success, PEAR_Error on failure

Parameters:

string   $pageID   —  page/group ID

[ Top ]

update   [line 283]

mixed update( string $stringID, string $pageID, array $stringArray)

Update an existing translation
  • Return: true on success, PEAR_Error on failure

Parameters:

string   $stringID   —  string ID
string   $pageID   —  page/group ID
array   $stringArray   —  Associative array with string translations. Sample format: array('en' => 'sample', 'it' => 'esempio')

[ Top ]

updateLang   [line 239]

mixed updateLang( array $langData)

Update the lang info in the langsAvail table
  • Return: true on success, PEAR_Error on failure

Parameters:

array   $langData   —  array containing language info

[ Top ]


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