PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » Translation2 » Bug #10087

i18n table creation failed and lang_avail table not created

Details

Submitted2007-02-13 14:53 UTC
Fromjukka at papinkivi dot fi
Assignedquipo
StatusClosed
PackageTranslation2
PHP VersionIrrelevant
OSDebian sarge/etch
Roadmaps(Not assigned)

Comments

[2007-02-13 14:53 UTC] jukka at papinkivi dot fi

Description:
------------
I use MDB2 ja mysql5. And I tested this in php4 and php5.

When testing the first example in Admin_Introduction
$tr->addLang($newLang) fails.

i18n table is created, but alter table fails (which trying to create unique index). Finally lang_avail table is never created.

Fix which works for me
======================
Modify file:
Translation2/Admin/Container/mdb2.php

To contain this section:
$constraint_definition = array(
'fields' => array(
$this->options['string_page_id_col'] => array(),
$this->options['string_id_col'].'(255)' => array()
),
'unique' => array(1=>0) //seems to need some array
);

Maybe this is already fixed in cvs. I haven't tested it yet.

Test script:
---------------
Documentation example in section Admin_Introduction.

<?php
// set the parameters to connect to your db
$dbinfo = array(
'hostspec' => 'host',
'database' => 'dbname',
'phptype' => 'mysql',
'username' => 'user',
'password' => 'pwd'
);

// tell Translation2 about your db-tables structure,
// if it's different from the default one.
$params = array(
'langs_avail_table' => 'langs_avail',
'lang_id_col' => 'id',
'lang_name_col' => 'name',
'lang_meta_col' => 'meta',
'lang_errmsg_col' => 'error_text',
'lang_encoding_col' => 'encoding',
'strings_tables' => array(
'it' => 'i18n',
'de' => 'i18n'
),
//OR, if you use only one table,
//'strings_default_table' => 'i18n',
'string_id_col' => 'id',
'string_page_id_col' => 'page_id',
'string_text_col' => '%s' //'%s' will be replaced by the lang code
);

$driver = 'MDB2';

require_once 'Translation2/Admin.php';
$tr =& Translation2_Admin::factory($driver, $dbinfo, $params);

// set some info about the new lang
$newLang = array(
'lang_id' => 'en',
'table_name' => 'i18n',
'name' => 'english',
'meta' => 'some meta info',
'error_text' => 'not available',
'encoding' => 'iso-8859-1',
);

$tr->addLang($newLang);
?>

Expected result:
----------------
Tables i18n and langs_avail in database dbname

Actual result:
--------------
Only table i18n with incorrect indexes