Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

request #15000: added new example (sql + php settings) for usage with…

… 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...
commit 21f4ce7a58622e4c705d9a4a890f7fd57337c428 1 parent 1ef6c75
@quipo quipo authored
View
1  docs/examples/Translation2_example.php
@@ -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';
View
37 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');
View
12 docs/examples/settings.php
@@ -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',
@@ -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)
);
-?>
View
31 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';
Please sign in to comment.
Something went wrong with that request. Please try again.