Start nice i18n
* Set everything up TODO: Replace all strings by i18n strings in templates and PHP code.
This commit is contained in:
parent
337c3d81f0
commit
7f547b94d9
2
i18n/en.php
Normal file
2
i18n/en.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Provided lang = English
|
2
i18n/fr.php
Normal file
2
i18n/fr.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Provided lang = French
|
@ -61,7 +61,7 @@
|
||||
return 18;
|
||||
}
|
||||
|
||||
function listTemplates($dir) {
|
||||
function listTemplates($dir='tpl/') {
|
||||
if(strrpos($dir, '/') !== strlen($dir) - 1) {
|
||||
$dir .= '/';
|
||||
}
|
||||
@ -79,6 +79,33 @@
|
||||
return $return;
|
||||
}
|
||||
|
||||
function listLangs($dir='i18n/') {
|
||||
if(strrpos($dir, '/') !== strlen($dir) - 1) {
|
||||
$dir .= '/';
|
||||
}
|
||||
|
||||
$return = array();
|
||||
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != ".." && is_file($dir.$entry)) {
|
||||
$trad = file($dir.$entry);
|
||||
foreach ($trad as $line) {
|
||||
if (strstr($line, '// Provided lang')) {
|
||||
$lang = explode('=', $line);
|
||||
$lang = trim($lang[1]);
|
||||
|
||||
$return[] = array('value'=>$entry, 'option'=>$lang);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function TwoDArrayToOneD($array, $key) {
|
||||
$return = array();
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
17
install.php
17
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 @@
|
||||
<em>For example:</em> Europe/Paris. See the doc for more info.
|
||||
</p>
|
||||
<p><label for="email_webmaster">Webmaster's email (optionnal): </label><input type="text" name="email_webmaster" id="email_webmaster" <?php echo (!empty($_POST['currency']) ? 'value="'.htmlspecialchars($_POST['email_webmaster']).'"' : '');?>/></p>
|
||||
<p><label for="lang">Lang: </label><select name="lang" id="lang"><option value="en">English</option><option value="fr">French</option></select></p>
|
||||
<p>
|
||||
<label for="lang">Lang: </label>
|
||||
<select name="lang" id="lang">
|
||||
<?php
|
||||
foreach (listLangs() as $value) {
|
||||
?>
|
||||
<option value="<?php echo $value['value'];?>" <?php echo ($value['value'] == $current_lang ? 'selected="selected"' : ''); ?>><?php echo $value['option']; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="template">Template : </label>
|
||||
<select name="template" id="template">
|
||||
|
@ -55,7 +55,14 @@
|
||||
{/loop}
|
||||
</select
|
||||
</p>
|
||||
<p><label for="lang">Lang: </label><select name="lang" id="lang">TODO</select></p>
|
||||
<p>
|
||||
<label for="lang">Lang: </label>
|
||||
<select name="lang" id="lang">
|
||||
{loop="$available_lang"}
|
||||
<option value="{$value['value']}" {if="$value['value'] == $current_lang"}selected="selected"{/if}>{$value['option']}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
</p>
|
||||
<p><label for="email_webmaster">Webmaster's email (optionnal): </label><input type="text" name="email_webmaster" id="email_webmaster" value="{$email_webmaster}"/></p>
|
||||
</fieldset>
|
||||
<p class="center"><input type="submit" value="Update settings"><input type="hidden" name="token" value="{$token}"/></p>
|
||||
|
Loading…
Reference in New Issue
Block a user