Skip to content

Commit

Permalink
request #15000: added new example (sql + php settings) for usage with…
Browse files Browse the repository at this point in the history
… one table per language

git-svn-id: http://svn.php.net/repository/pear/packages/Translation2/trunk@268996 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
quipo committed Nov 14, 2008
1 parent 1ef6c75 commit 21f4ce7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/examples/Translation2_example.php
Expand Up @@ -4,6 +4,7 @@
* set parameters and options
*/
require_once './settings.php';
//require_once './settings_multitable.php'; //this one uses one table per lang
require_once 'Translation2.php';

//require_once 'Translation2/Admin.php';
Expand Down
37 changes: 37 additions & 0 deletions docs/examples/Translation2_example_multitable.sql
@@ -0,0 +1,37 @@
CREATE TABLE i18n_de (
string_id varchar(100) NOT NULL DEFAULT '',
page_id varchar(100) DEFAULT NULL,
string text,
UNIQUE KEY id (string_id,page_id)
);

CREATE TABLE i18n_en (
string_id varchar(100) NOT NULL DEFAULT '',
page_id varchar(100) DEFAULT NULL,
string text,
UNIQUE KEY id (string_id,page_id)
);

CREATE TABLE i18n_it (
string_id varchar(100) NOT NULL DEFAULT '',
page_id varchar(100) DEFAULT NULL,
string text,
UNIQUE KEY id (string_id,page_id)
);

INSERT INTO i18n_en (string_id, page_id, string) VALUES ('smallTest',NULL,'very small test');
INSERT INTO i18n_de (string_id, page_id, string) VALUES ('smallTest',NULL,'kinder');
INSERT INTO i18n_it (string_id, page_id, string) VALUES ('smallTest',NULL,'piccolissimo test');


CREATE TABLE langs_avail (
id varchar(10) NOT NULL DEFAULT '',
name varchar(200) DEFAULT NULL,
meta text,
error_text varchar(250) DEFAULT NULL,
encoding varchar(16) DEFAULT NULL,
UNIQUE KEY ID (id)
);
INSERT INTO langs_avail (id, name, meta, error_text, encoding) VALUES ('it','italiano','charset: UTF-8','non disponibile in Italiano','UTF-8');
INSERT INTO langs_avail (id, name, meta, error_text, encoding) VALUES ('en','english','my meta info','not available in English','UTF-8');
INSERT INTO langs_avail (id, name, meta, error_text, encoding) VALUES ('de','deutsch','charset: UTF-8','kein Text auf Deutsch verfügbar','UTF-8');
12 changes: 6 additions & 6 deletions docs/examples/settings.php
Expand Up @@ -43,10 +43,11 @@ function getValue($var, $color='red')

$params = array(
'langs_avail_table' => TABLE_PREFIX.'langs_avail',
'lang_id_col' => 'id',
'lang_name_col' => 'name',
'lang_meta_col' => 'meta',
'lang_errmsg_col' => 'error_text',
'lang_id_col' => 'id',
'lang_name_col' => 'name',
'lang_meta_col' => 'meta',
'lang_errmsg_col' => 'error_text',
'lang_encoding_col' => 'encoding',
/*
'strings_tables' => array(
'en' => TABLE_PREFIX.'i18n',
Expand All @@ -62,10 +63,9 @@ function getValue($var, $color='red')
//(use when db load is cheaper than network load)
);

$driver = 'MDB';
$driver = 'MDB2';

$cache_options = array(
'cacheDir' => 'cache/', //default is /tmp/
'lifeTime' => 3600*24, //default is 3600 (1 minute)
);
?>
31 changes: 31 additions & 0 deletions docs/examples/settings_multitable.php
@@ -0,0 +1,31 @@
<?php
define('TABLE_PREFIX', '');

$dbinfo = array(
'hostspec' => 'host',
'database' => 'dbname',
'phptype' => 'mysql',
'username' => 'user',
'password' => 'pwd'
);

$params = array(
'langs_avail_table' => TABLE_PREFIX.'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(
'en' => TABLE_PREFIX.'i18n_en',
'it' => TABLE_PREFIX.'i18n_it',
'de' => TABLE_PREFIX.'i18n_de'
),
'string_id_col' => 'string_id',
'string_page_id_col' => 'page_id',
'string_text_col' => 'string'
//'prefetch' => false //more queries, smaller result sets
//(use when db load is cheaper than network load)
);

$driver = 'MDB2';

0 comments on commit 21f4ce7

Please sign in to comment.