Translation class
Class allows storing and retrieving all the strings on multilingual site in a database. The class connects to any database using PEAR::DB extension - so it needs PEAR to be installed to work correctly. The object should be created for every page. While creation all the strings connected with specific page and the strings connected with all the pages on the site are loaded into variable, so accessing them is quite fast and does not overload database server connection. The class can reuse existing DB connections. To do so just pass to the constructor the handle for the connection instead of DSN.
PEAR | --Translation
Class | Description |
---|---|
TTranslationUTF8 | class that allows using Translation class with UTF-8 DB encoding |
Is true if the connection was reused, not made from the class
Connection to database
The string that will be displayed, if no string has been found in the
DB for specified string_id
Language identifier
Page identifier
Strings of the given page array
This one is for fast access to cached strings for specified page
The array with table and column names
The table may have following items:
'langsavail' - table, in which all the information of the possible languages is kept. This array item may be the string - then the structure of the table remains as original, but the name is specified here; or the array with the following items: 'name' - the name of the table - default is 'tr_langsavail' 'lang_id' - the column that stores the language identifier - default is 'lang_id' 'lang_name' - the column that stores the language name - default is 'name' 'metatags' - the column that stores meta tags for the pages in specified language - default is 'metatags' 'errortext' - the column that stores the text that will be displayed in case if some text will not be found in the DB - default is 'errortext'
'strings_XX' - table, in which the strings of language "XX" (the corresponding lang_id) are kept. This array item may be the string - then the structure of the table remains as original, but the name is specified here; or the array with the following items: 'name' - the name of the table - default is 'tr_strings_XX' 'page_id' - the page identifier - default is 'page_id'. 'string_id' - the string indetifier - default is 'string_id'. 'string' - the string itself - default is 'string'.
This parameter in fact has impact only if the DB is used as the strings repository. The defaults are set in the way that the method is compatible with lower versions.
Class constructor
Class destructor
Active language name retrieval
Retrieves the name of active language
META tags retrieval
Retrievs the META tags that should be added on the top of translated page, so the translated characters will be correctly displayed on client's browser.
Other languages retrieval
Retrieves names of all other languages, not the active.
Translated string retrieval
Retrieves the string basing on string identifier (string_id) or by page_id.string_id. It means the strings_id may be specified in 2 ways:
Documentation generated on Tue, 20 Jan 2004 22:54:55 +0100 by phpDocumentor 1.2.3