For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2005 > PEAR Package Translation2 returns error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PEAR Package Translation2 returns error
Philliph Mau

2005-08-20, 6:56 pm

I tried to install PEAR::Translation2. PEAR ist installed correctly,
because all the other functions of I18Nv2 seems to work correctly.
But I also need multilingual support. This is supported by
PEAR::Translation2.

Does anybody have any experiences with this class?

This is my code, that does not work:


------
require_once 'Translation2.php';

define('TABLE_PREFIX', 'db_');
define('LANGUAGE_TABLE', 'tanslations');

$params = array(
langs_avail_table => TABLE_PREFIX."_languages",
lang_id_col => "id",
lang_meta_col => "iso",
lang_name_col => "language",
lang_errmsg_col => "error",
strings_tables=> array(
en => TABLE_PREFIX.LANGUAGE_TABLE,
de => TABLE_PREFIX.LANGUAGE_TABLE,
it => TABLE_PREFIX.LANGUAGE_TABLE
),
string_id_col=> "id",
string_page_id_col => "group",
string_text_col=> "%s"
);

$dsn =
"mysql://".DB_SERVER_USERNAME.":".DB_SERVER_PASSWORD."@".DB_SERVER."/".DB_DATABASE;

$tr =& Translation2::factory('DB', $dsn, $params);

// add a Lang decorator to provide a fallback language
$tr =& $tr->getDecorator('Lang');
$tr->setOption('fallbackLang', 'en');

// set primary language
$tr->setLang('en');

// set the group of strings you want to fetch from
$tr->setPageID('TEST');

// add another Lang decorator to provide another fallback language,
// in case some strings are not translated in Italian or English
//$tr =& $tr->getDecorator('Lang');
//$tr->setOption('fallbackLang', 'de');

// fetch the string with the 'test' stringID
echo $tr->get(1);
------

I receive always this Warning:

Warning: No valid language set. Use Translation2::setLang(). in
C:\PHP\PEAR\PEAR.php on line 842



Can anybody help me?


-phil
Object id #10
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com