Home » Internationalization » Translation2
Class for multilingual applications management.
This package is unmaintained.
Download latest release 2.0.4 (archived versions might be outdated)
License: BSD
Description
This class provides an easy way to retrieve all the strings for a multilingual site from a data source (i.e. db).
The following containers are provided, more will follow:
- PEAR::DB
- PEAR::MDB
- PEAR::MDB2
- gettext
- XML
- PEAR::DB_DataObject (experimental)
It is designed to reduce the number of queries to the db, caching the results when possible.
An Admin class is provided to easily manage translations (add/remove a language, add/remove a string).
Currently, the following decorators are provided:
- CacheLiteFunction (for file-based caching)
- CacheMemory (for memory-based caching)
- DefaultText (to replace empty strings with their keys)
- ErrorText (to replace empty strings with a custom error text)
- Iconv (to switch from/to different encodings)
- Lang (resort to fallback languages for empty strings)
- SpecialChars (replace html entities with their hex codes)
- UTF-8 (to convert UTF-8 strings to ISO-8859-1)
Documentation
Maintainers
- Lorenzo Alberton (quipo) — lead, active
- Ian Eure (ieure) — developer, active
- Michael Wallner (mike) — developer, active
Dependencies
Required
- PHP (>= 4.0.0)
- PEAR Installer (>= 1.4.0b1)
Optional
- Cache_Lite
- DB
- DB_DataObject
- MDB
- MDB2
- File_Gettext
- I18Nv2 (>= 0.9.1)
- XML_Serializer (>= 0.13.0)
- gettext (extension)
Releases
- 2.0.4 (stable, 2010-12-05)
Release notes
License: BSD
QA release
Bug #18081 Translation2.php installed in the wrong place - 2.0.3 (stable, 2010-10-25)
Release notes
License: BSD
Automatically built QA release
Req #16787 default 'latin1_swedish_ci' db created with collation set to
utf8_unicode_ci - quipo - 2.0.1 (stable, 2008-11-14)
Release notes
License: BSD
- fixed bug #13933: undefined variable in the dataobjectsimple driver
- fixed bug #14323: wrong / no error from setLang() [cwiedmann]
- fixed bug in getLangs(), where certain formats were not recognized
- request #14979: fluent interface for setPageID() and setParams()
and for setOption() and setOptions() decorator methods
- request #15000: added SQL example in the /docs/examples dir - 2.0.0 (stable, 2008-05-06)
Release notes
License: BSD
- fixed a few PHP5 NOTICEs
- request #13734: added 'string_page_id_col_length' option to set the size of the
pageID field in the translations table - 2.0.0RC4 (beta, 2008-02-23)
Release notes
License: BSD
- fixed bug #12703: CacheLiteFunction decorator and getLang() issue
- fixed some E_STRICT warnings
- fixed getStringID() - 2.0.0RC3 (beta, 2007-12-05)
Release notes
License: BSD
- fixed bug #12525: moved t2xmlchk.php script to / baseinstalldir
- fixed bug #12527: rewritten CacheMemory Decorator to properly prefetch pages - 2.0.0RC2 (beta, 2007-11-25)
Release notes
License: BSD
- request #11711: added setCharset() method in the DB container
- bug #11880: [XML driver] removing one language removes all strings for all languages
- request #11881: getLang(..., 'array') now returns a 'lang_id' alias to 'id'
- bug #12183: language ID '0' considered invalid
- bug #12398: fixed return value of addLangToList() and updateLang() in the MDB2
admin container
- request #12405: added removePage() method in the Admin module
- added getLang() and getLangs() to the CacheLiteFunction Decorator
- fixed the test suite
- fixed Coding Standards - 2.0.0RC1 (beta, 2007-07-29)
Release notes
License: BSD
- fixed bug #9855: missing call to _prepare() in setLang()
- propagate errors in the decorators
- fixed testsuite: added missing db_test_base.php file and
fixed problem with class redeclaration
- fixed constraint creation in addLang() in the MDB2 Admin driver
- fixed setCharset() proxy in the Decorator
- fixed bug #11482: missing return in Translation2_Admin_Container_mdb2::addLang()
when the table already exists - 2.0.0beta12 (beta, 2006-12-15)
Release notes
License: BSD
- force MDB2_FETCHMODE_ORDERED in Translation2_Container_mdb2::getPage() to
avoid error when using an existing db connection with fetchmode set to
MDB2_FETCHMODE_ASSOC (bug #8734)
- force lowercase keys in fetchLang() for Oracle compatibility (bug #8915)
- added defaultGroup to cache_lite options
- added new $options optional parameter to addLang() to set charset/collate info
(MDB2 driver only)
- fixed bug #8546: index names are not escaped in SQL queries (DB and MDB admin
containers)
- fixed dataobjectsimple container, get[Raw]Page() was returning integers as
keys instead of strings (thanks to Michael Henry)
- added setCharset() method (currently only implemented in the MDB2 driver)
- added setLang() and setCacheOption() in CacheLiteFunction decorator (request #9301)
(thanks to Sascha Grossenbacher)
- fixed bug #5539: DefaultText decorator does not call _replaceParams() - 2.0.0beta11 (beta, 2006-09-07)
Release notes
License: BSD
- fixed an error that would result in losing strings when getting a specific
language's string in Translation2_Admin_Decorator_Autoadd.
- fixed bug #8287: addLang() SQL not compatible with MSSQL
- fixed MDB/MDB2 test runner
- fixed bug #8546: column/table names are not escaped in SQL queries - 2.0.0beta10 (beta, 2006-07-12)
Release notes
License: BSD
- fixed bug #7058, issue with array_merge not respecting existing array keys
- request #7736: ability to specify CacheLite group for CacheLite Decorator
(thanks to ajt at localhype dot net)
- if an empty xml file is given, don't return an error (bug #7793)
- propagate errors in getPage() and getOne() (bug #8127)
- Fix Autoadd decorator, which was not adding entries for new string IDs for all languages,
which made update() to fail on those strings. - 2.0.0beta9 (beta, 2006-02-22)
Release notes
License: BSD
- Translation2_Decorator_Lang: append keys when fallback lang
contains more than current (request #5773)
- Removed leftover code from the MDB admin container that caused
inserting the same record twice (bug #6233)
- Better error handling and cache refreshing in the gettext driver
(bug #6410) [thanks to Alan Knowles and ivanwyc@gmail.com]
- Honor global PEAR error settings in Translation2_Container::raiseError()
(bug #6574)
- Added missing updateLang() proxy in Translation2_Admin_Decorator (bug #6753)
- Added length to INDEX on TEXT column in Translation2_Admin::addLang()
when the dbms is MySQL (thanks to AJ Tarachanowicz)
- Fixed UNIQUE INDEX in Translation2_Admin::addLang(), one of the two columns
got lost in a previous revision - 2.0.0beta8 (beta, 2005-10-04)
Release notes
License: BSD
- changed license to BSD
- removeLang() used to drop the entire table if there weren't any languages left.
Now it does so only if the $force parameter is set (request #4218 and #5142)
- Translation2_Decorator now extends Translation2
- fixed warning with the CacheLiteFunction decorator and PHP 5.1 - 2.0.0beta7 (beta, 2005-06-28)
Release notes
License: PHP License
- added some options to the DefaultText decoration, now it is more customizable
(thanks to Rolf 'Red' Ochsenbein)
- added a __clone() method to clone the internal object references
(bug #3641, patch by Olivier Guilyardi)
- Some fixes to the XML container, many thanks to Olivier Guilyardi:
* fixed bug #3408: empty data sets were not correctly handled;
* fixed bug #3420: get a shared file lock instead of an exclusive one;
* fixed bug #3498: saveData() is not registered multiple times as shutdown
function anymore; optimized saving when save_on_shutdown is set to false.
- added blank_on_missing option to the gettext container, which makes it
behave like the other containers and automatically disables native mode;
* see bug #4002
- fixed bug #4476: gettext container not working without the gettext extension
(thanks to sergey at pushok dot com)
- added setContainerOptions() method to alter some container options after
the object instantiation (bug #2508)
- some minor fixes - 2.0.0beta6 (beta, 2005-01-30)
Release notes
License: PHP License
- added Translation2::getRaw()
- fixed bug #3068: Translation2_Admin::update() on multiple tables didn't insert
new records for missing langs, only updated the existing ones.
- fixed bug #3149: XML container didn't properly handle redundant strings
- added TRANSLATION2_DTD constant to the xml container (thanks to Olivier Guilyardi)
- added t2xmlchk.php script to check if a XML file is Translation2 compliant
(thanks to Olivier Guilyardi)
- added ErrorText decorator - 2.0.0beta5 (beta, 2004-12-24)
Release notes
License: PHP License
- renamed createNewLang() to addLang() [BC break!]
- renamed addLangToAvailList() to addLangToList()
- added Translation2_Admin::getPageNames()
- added Translation2_Admin::updateLang()
- fixed bug #2890: getLang() raised a NOTICE if setLang() was not called before
- fixed bug #2972: CacheLiteFunction decorator not handling
parameter subtitution as expected
- updated dataobjectsimple container (alank)
- some internal minor fixes and tweaks - 2.0.0beta4 (beta, 2004-11-20)
Release notes
License: PHP License
- added a complete TestSuite
- updated gettext docs
- fixed typo in error code (TRANSLATION_ERROR_UNKNOWN_LANG => TRANSLATION2_ERROR_UNKNOWN_LANG)
- fixed typo in the MDB Admin container [quote() => getTextValue()]
- fixed typo in db admin containers ($this->queries => $this->_queries)
- in the gettext admin container
- fixed many bugs in the gettext admin container:
* fixed old field [remove "windows", add "encoding"]
* fixed error in remove() [can't pass by reference]
* fixed typo in update() [$stingID => $stringID]
* in _add(), create the domains on demand
* handle stale cache
- many fixes/updates to the xml container:
* init() accepts an array as parameter (not a string)
* added 'save_on_shutdown' option
(you can choose to save in real time, now)
* return Translation2 errors with numeric codes
* added 'encoding' field
* added removeLang()
* other minor fixes and tweaks - 2.0.0beta3 (beta, 2004-11-11)
Release notes
License: PHP License
- Welcome to the new developers, Ian Eure and Michael Wallner
- The last release contained an old gettext driver (bug #2503) (ieure)
- Many portability fixes applied to the database containers (thanks to Ian Eure and
Xavier Lembo for their suggestions and patches)
- Minor changes to the table definitions for better portability (lowercase field names,
VARCHAR instead of CHAR, bigger field size)
- setLang() now returns an error if called with an unknown $langID (bug #2498).
- Added $cleaningFrequency option to the CacheLiteFunction to implement
statistic cache cleaning
- Added Translation2_Admin::cleanCache() method to clean the cache on demand.
It is automatically triggered after a change if $options['autoCleanCache'] is TRUE.
- Big cleanup of the DB and Admin_DB containers. See CVS changelog for details.
(ieure)
- Added update() method to Translation2_Admin. This is a BC break; you used to be able
to update strings with add(). This is no longer possible, use update(). (ieure)
- Re-added a check in add() to see if an update() is needed instead of an insert
- String ID columns are created as type TEXT to support gettext-style string IDs.
(ieure)
- Reflect the changes made to the DB container into the MDB and MDB2 containers too,
plus other minor fixes/optimizations.
- strings_default_table may use %s to represent the language name. You may now have one
table per language without having to explicitly specify them all. (ieure)
- DefaultText decorator has new getStringID() method, which will return the string which
was requested if no stringID exists. This mirrors the gettext() semantics. (ieure)
- Added Admin_Decorator class, which allows you to create Decorators for
Translation2_Admin. (ieure)
- New 'Autoadd' Admin Decorator, which automatically adds requested strings. (ieure)
- Removed translate(), added getStringID(). You can mimic the old behaviour in
two steps:
$stringID = $tr->getStringID('mystring', 'mypage');
$translatedString = $tr->get($stringID, 'mypage', $otherLangID);
- Major cleanup of the gettext container and added some examples (mike)
- removeLang() was missing. Fixed.
- The gettext container no longer require the gettext extension (thanks to Sergey Korotkov);
it is used when loaded, though, since it's faster.
- Both .mo and .po files are valid data sources for the gettext container (Sergey Korotkov)
- New Iconv decorator based on the one written by Sergey Korotkov
- Added a new "encoding" column to the langsAvail table
- New xml container by Olivier Guilyardi - 2.0.0beta2 (beta, 2004-10-04)
- 2.0.0beta1 (beta, 2004-05-05)
Release notes
License: PHP License
- BC break! Run the example to see what's new
- refactoring in progress:
added a Decorator class and some subclasses to control
the output (now you can set a stack of fallback languages,
a filter to deal with empty strings, one or more cache layers...)
- improved gettext support (thanks to Michael Wallner)
- added gettext admin class
- fixes in the db admin classes
- when adding a new string, if it matches one already in the db,
the old one is replaced by the new one.
- added a MDB2 container
- added a DB_DataObject container (by Alan Knowles) - 2.0.0alpha2 (alpha, 2004-02-22)
Release notes
License: PHP License
- added an experimental GNU gettext driver
- translate() now accepts a third parameter ($pageID)
- PHP5 fix
- renamed old getPage() to getRawPage()
- new getPage() resorts to fallback lang and replaces parameters when needed
- added error checking/codes - 0.0.1 (alpha, 2004-01-20)
Release notes
License: PHP License
First alpha release
Bugs
| ID | Status | Type | Version | Date | Summary |
|---|---|---|---|---|---|
| #1769 | Closed | Bug | 2004-07-02 | Typo in example | |
| #1825 | Closed | Req | 2004-07-08 | no table prefix delivered to class? | |
| #2153 | Closed | Bug | 2004-08-17 | Translation2_Admin_Container_db can't alter table, only create new ones | |
| #2248 | Closed | Bug | 2004-08-29 | Translation2 Missing Language Index | |
| #2256 | Closed | Req | 2004-08-30 | Cache flushing/write update | |
| #2437 | Bogus | Bug | 2004-10-02 | createNewLang Admin Container SQL | |
| #2498 | Closed | Bug | 2004-10-11 | Translation2::setLang() misses errorhandling | |
| #2503 | Closed | Bug | 2004-10-11 | [PATCH] Gettext container is broken | |
| #2508 | Closed | Req | 2004-10-11 | Cant change options after calling Translation2::factory() | |
| #2543 | Closed | Bug | 2004-10-15 | [PATCH] DB Admin container uses non-portable 'SHOW TABLES' | |
| #2546 | Closed | Bug | 2004-10-16 | [PATCH] DB Admin container uses non-portable CREATE ... KEY / UNIQUE KEY syntax | |
| #2563 | Closed | Req | 2004-10-18 | [PATCH] Admin_DB add/update cleanup | |
| #2564 | Closed | Bug | 2004-10-18 | [PATCH] Admin DB update() doesn't work with single table | |
| #2570 | Closed | Req | 2004-10-19 | Missing Admin::update() | |
| #2619 | Wont fix | Req | 2004-10-26 | Falling back to language code if fully qualified locale is not available | |
| #2624 | Closed | Req | 2004-10-26 | XML Container | |
| #2629 | Closed | Bug | 2004-10-27 | Translation2_Admin::removeLang() does nothing (with db container) | |
| #2631 | Closed | Bug | 2004-10-27 | Translation2_Admin::add() produces duplicates | |
| #2665 | Duplicate | Req | 2004-11-01 | Translation2_Admin is not DB protable | |
| #2667 | Closed | Req | 2004-11-01 | method to fetch all page ids | |
| #2711 | Closed | Bug | 2004-11-07 | CVS' Translation2_example.sql fails | |
| #2844 | Closed | Req | 2004-11-28 | Documentation bug in createNewLang() of admin class | |
| #2890 | Closed | Bug | 2004-12-04 | getLang() notices if setLang() is not falled before | |
| #2891 | Closed | Bug | 2004-12-04 | getPageNames() returns duplicate names | |
| #2893 | Closed | Req | 2004-12-04 | please add a method for updating language information | |
| #2953 | No Feedback | Bug | 2004-12-12 | getPage when using database container throws SQL syntax error | |
| #2972 | Closed | Bug | 2004-12-15 | cache_lite decorator not handling param sub as expected | |
| #3007 | Closed | Req | 2004-12-21 | Documentation request | |
| #3008 | Bogus | Req | 2004-12-21 | getCharset() | |
| #3065 | Closed | Req | 2004-12-30 | getRaw() missed | |
| #3068 | Closed | Bug | 2004-12-30 | Admin::update() buggy | |
| #3105 | Closed | Req | 2005-01-05 | Using the default Lang with Admin methods | |
| #3149 | Closed | Bug | 2005-01-10 | XML container does not properly handle redundant strings | |
| #3272 | Closed | Bug | 2005-01-23 | Translation2::get() has unused parameter defaulttext | |
| #3408 | Closed | Bug | 2005-02-08 | XML container : empty data sets badly handled | |
| #3420 | Closed | Bug | 2005-02-09 | XML Container lacks shared lock | |
| #3498 | Closed | Bug | 2005-02-16 | XML container: several add() produce encoding junk | |
| #3641 | Closed | Bug | 2005-02-28 | Translation2 is not cloneable | |
| #3914 | Closed | Bug | 2005-03-22 | Translation2 'CacheMemory' Decorator class get() bug! | |
| #4002 | Closed | Bug | 2005-03-30 | fallbackLang does not work with gettext container | |
| #4218 | Closed | Bug | 2005-04-25 | Admin Container removeLang bug | |
| #4227 | Closed | Bug | 2005-04-26 | Error in the saple code | |
| #4476 | Closed | Bug | 2005-05-30 | GetText !_native not works without gettext extension | |
| #5142 | Closed | Bug | 2005-08-18 | Bug in removeLang | |
| #5170 | Bogus | Bug | 2005-08-21 | setLang will not work | |
| #5539 | Closed | Bug | 2005-09-27 | DefaultText decorator does not call _replaceParams | |
| #5773 | Closed | Req | 2005-10-25 | Decorator - Lang - append keys when fallback lang contains more than current | |
| #6137 | Bogus | Bug | 2005-12-03 | Problem with XML container, using Translation2_Admin | |
| #6227 | Closed | Bug | 2005-12-12 | Typo in function _fetchTableNames() | |
| #6233 | Closed | Bug | 2005-12-12 | calling Translation2_Admin::add() adds tranlslation twice | |
| #6270 | Closed | Bug | 2005-12-16 | Latin1 returned instead of UTF-8 | |
| #6410 | Closed | Bug | 2006-01-04 | Various fixes to gettext backend error handling | |
| #6574 | Closed | Bug | 2006-01-24 | Translation2_Container::raiseError does not honor global PEAR error settings | |
| #6585 | Bogus | Bug | 2006-01-25 | Admin add string | |
| #6753 | Closed | Bug | 2.0.0beta8 | 2006-02-11 | Missing method updateLang from Translation2_Admin_Decorator class |
| #7058 | Closed | Bug | 2.0.0beta9 | 2006-03-08 | array_merge breaks bc in decorator |
| #7573 | Bogus | Bug | CVS | 2006-05-07 | Fatal error: Class 'MDB2' not found |
| #7576 | Bogus | Bug | 2006-05-08 | Fatal error: Call to undefined method MDB2_Error::setLang() | |
| #7736 | Closed | Req | CVS | 2006-05-28 | Ability to specify CacheLite group for CacheLite Decorator |
| #7793 | Closed | Bug | 2.0.0beta9 | 2006-06-02 | XML container not working |
| #8127 | No Feedback | Bug | 2.0.0beta9 | 2006-07-06 | '0' isn't an empty string |
| #8128 | Closed | Bug | 2.0.0beta9 | 2006-07-06 | getPage() does not work |
| #8331 | Closed | Bug | 2.0.0beta10 | 2006-07-31 | AddLang() SQL not compatible with MSSQL |
| #8546 | Closed | Bug | 2.0.0beta10 | 2006-08-23 | column/table names are not escaped in SQL queries |
| #8547 | Closed | Bug | 2006-08-23 | Documentation is missing a column on "default db structure" | |
| #8734 | Closed | Bug | 2.0.0beta11 | 2006-09-19 | Wrong use of list() |
| #8915 | Closed | Bug | 2006-10-09 | Fetching vom Database does not work with Oracle | |
| #9239 | Closed | Doc | 2.0.0beta11 | 2006-11-05 | Documentation for Database Containers - encoding |
| #9297 | Closed | Req | 2.0.0beta11 | 2006-11-10 | More parameters please |
| #9301 | Closed | Req | 2.0.0beta11 | 2006-11-10 | [PATCH] Caching setLang() and setCacheOption() |
| #9457 | Wont fix | Req | 2.0.0beta11 | 2006-11-25 | Direction column in database |
| #9855 | Closed | Bug | 2.0.0beta12 | 2007-01-17 | missing $this->_prepare(); call |
| #10058 | Closed | Bug | 2.0.0beta12 | 2007-02-08 | MDB2 Driver: createConstraint fails |
| #10086 | No Feedback | Bug | 2.0.0beta12 | 2007-02-13 | Container gettext is missing a way to set default langID on the getOne method |
| #10087 | Closed | Bug | 2.0.0beta12 | 2007-02-13 | i18n table creation failed and lang_avail table not created |
| #11482 | Closed | Bug | 2.0.0beta12 | 2007-06-29 | Call of addLang with existing languages with MDB2 results in error |
| #11880 | Closed | Bug | 2.0.0RC1 | 2007-08-21 | Removing _one_ language removes all strings for _all_ languages |
| #11881 | Closed | Bug | 2.0.0RC1 | 2007-08-21 | Translation2::getLang(...,'array') returns ID as 'id' instead of 'lang_id' |
| #12183 | Closed | Bug | 2.0.0RC1 | 2007-10-04 | Default language ID '0' considered to be invalid |
| #12396 | Closed | Bug | 2.0.0RC1 | 2007-11-07 | Bug in Admin/Container/mdb2.php addLang |
| #12398 | Closed | Bug | 2.0.0RC1 | 2007-11-07 | updateLang returns incorrect type |
| #12400 | Wont fix | Req | 2.0.0RC1 | 2007-11-08 | request for new method in Admin class |
| #12405 | Closed | Req | 2.0.0RC1 | 2007-11-08 | request for new method in Admin class |
| #12525 | Closed | Bug | 2.0.0RC2 | 2007-11-25 | t2xmlchk.php script has wrong baseinstalldir |
| #12527 | Closed | Bug | 2.0.0RC2 | 2007-11-26 | CacheMemory doesn't properly prefetch pages |
| #12703 | Closed | Bug | 2.0.0RC3 | 2007-12-16 | CacheLiteFunction decorator and getLang() issue |
| #13734 | Closed | Req | CVS | 2008-04-21 | Dynamic page_id column length |
| #13933 | Closed | Bug | 2.0.0 | 2008-05-18 | Translation2_Container_dataobjectsimple::getOne() - undefined variable $string |
| #14277 | Closed | Bug | 2.0.0 | 2008-07-02 | Result from method getLang differs depending on cache decorator |
| #14282 | Closed | Req | 2.0.0 | 2008-07-02 | Normalize DB table scheme |
| #14323 | Closed | Bug | 2.0.0 | 2008-07-10 | wrong / no error from setLang() |
| #14979 | Closed | Req | 2.0.0 | 2008-11-09 | Fluent interface for setOption() |
| #15000 | Closed | Bug | 2.0.0 | 2008-11-12 | Translation table schema missing |
| #15975 | Wont fix | Req | 2009-03-04 | need extra condition check to Lang decorator | |
| #16787 | Closed | Req | 2.0.1 | 2009-11-13 | default 'latin1_swedish_ci' db created with collation set to utf8_unicode_ci |
| #18081 | Closed | Bug | 2.0.3 | 2010-11-22 | Translation2.php installed in the wrong place |