From 7f547b94d9ba83e53fd94eadae8a019e2ee80270 Mon Sep 17 00:00:00 2001
From: Phyks
Date: Sat, 30 Aug 2014 23:57:12 +0200
Subject: [PATCH] Start nice i18n
* Set everything up
TODO: Replace all strings by i18n strings in templates and PHP code.
---
i18n/en.php | 2 ++
i18n/fr.php | 2 ++
inc/functions.php | 29 ++++++++++++++++++++++++++++-
index.php | 7 ++++---
install.php | 17 +++++++++++++++--
tpl/default/settings.html | 9 ++++++++-
6 files changed, 59 insertions(+), 7 deletions(-)
create mode 100644 i18n/en.php
create mode 100644 i18n/fr.php
diff --git a/i18n/en.php b/i18n/en.php
new file mode 100644
index 0000000..edf4e2a
--- /dev/null
+++ b/i18n/en.php
@@ -0,0 +1,2 @@
+$entry, 'option'=>$lang);
+ break;
+ }
+ }
+ }
+ }
+ closedir($handle);
+ }
+ return $return;
+ }
+
function TwoDArrayToOneD($array, $key) {
$return = array();
diff --git a/index.php b/index.php
index 8953967..716fa0e 100644
--- a/index.php
+++ b/index.php
@@ -413,7 +413,7 @@
break;
case 'settings':
- if(!empty($_POST['mysql_host']) && !empty($_POST['mysql_login']) && !empty($_POST['mysql_password']) && !empty($_POST['mysql_db']) && !empty($_POST['instance_title']) && !empty($_POST['base_url']) && !empty($_POST['currency']) && !empty($_POST['timezone']) && !empty($_POST['template'])) {
+ if(!empty($_POST['mysql_host']) && !empty($_POST['mysql_login']) && !empty($_POST['mysql_db']) && !empty($_POST['instance_title']) && !empty($_POST['base_url']) && !empty($_POST['currency']) && !empty($_POST['timezone']) && !empty($_POST['template'])) {
if(check_token(600, 'settings')) {
if(!is_writable('data/')) {
$tpl>assign('error', $errors['write_error_data'][LANG]);
@@ -447,7 +447,7 @@
elseif(strpos(trim($line), "TEMPLATE_DIR") !== false)
$config[$line_number] = "\tdefine('TEMPLATE_DIR', 'tpl/".$_POST['template']."/');\n";
elseif(strpos(trim($line), "LANG") !== false)
- $config[$line_number] = "\tdefine('LANG', '".substr($_POST['template'], -2)."');\n";
+ $config[$line_number] = "\tdefine('LANG', 'i18n/".$_POST['lang']."');\n";
elseif(strpos(trim($line), 'date_default_timezone_set') !== false)
$config[$line_number] = "\tdate_default_timezone_set('".$_POST['timezone']."');\n";
}
@@ -480,7 +480,8 @@
$tpl->assign('token', generate_token('settings'));
$tpl->assign('templates', secureDisplay(listTemplates('tpl/')));
$tpl->assign('current_template', htmlspecialchars(trim(substr(TEMPLATE_DIR, 4), '/')));
- $tpl->assign('lang', htmlspecialchars(LANG));
+ $tpl->assign('current_lang', htmlspecialchars(LANG));
+ $tpl->assign('available_lang', secureDisplay(listLangs()));
$tpl->draw('settings');
break;
diff --git a/install.php b/install.php
index 661186d..c59ba24 100644
--- a/install.php
+++ b/install.php
@@ -25,6 +25,7 @@
if(!empty($_POST['mysql_host']) && !empty($_POST['mysql_login']) && !empty($_POST['mysql_password']) && !empty($_POST['mysql_db']) && !empty($_POST['instance_title']) && !empty($_POST['base_url']) && !empty($_POST['currency']) && !empty($_POST['timezone']) && !empty($_POST['lang']) && !empty($_POST['template']) && !empty($_POST['admin_login']) && !empty($_POST['admin_password']) && check_token(600, 'install')) {
$mysql_prefix = (!empty($_POST['mysql_prefix'])) ? $_POST['mysql_prefix'] : '';
$current_template = $_POST['template'];
+ $current_lang = $_POST['lang'];
try {
$db = new PDO('mysql:host='.$_POST['mysql_host'].';dbname='.$_POST['mysql_db'], $_POST['mysql_login'], $_POST['mysql_password']);
@@ -127,7 +128,7 @@
define('CURRENCY', '".$_POST['currency']."');
define('EMAIL_WEBMASTER', '".$_POST['email_webmaster']."');
define('TEMPLATE_DIR', 'tpl/".$_POST['template']."');
- define('LANG', '".$_POST['lang']."');
+ define('LANG', 'i18n/".$_POST['lang']."');
date_default_timezone_set('".$_POST['timezone']."');
";
@@ -159,6 +160,7 @@
}
else {
$current_template = 'default';
+ $current_lang = 'en.php';
}
$token = generate_token('install');
@@ -209,7 +211,18 @@
For example: Europe/Paris. See the doc for more info.
/>
-
+
+
+
+
-
+
+
+
+