i18n system improved. Templates are localized.

This commit is contained in:
Phyks 2013-09-05 23:57:47 +02:00
parent 285661b00a
commit 2582594b37
3 changed files with 8 additions and 18 deletions

View File

@ -62,10 +62,7 @@
if ($handle = opendir($dir)) { if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && is_dir($dir.$entry)) { if ($entry != "." && $entry != ".." && is_dir($dir.$entry)) {
$entry = str_replace(array('_en', '_fr'), array('', ''), $entry); $return[] = array('value'=>$entry, 'option'=>str_replace(array('_en', '_fr'), array(' (English)', ' (French)'), $entry));
if(!in_array($entry, $return))
$return[] = $entry;
} }
} }
closedir($handle); closedir($handle);

View File

@ -8,7 +8,7 @@
'write_error_data'=>array('fr'=>'Le script ne peut pas écrire dans le dossier data/, vérifiez les permissions sur ce dossier.', 'en'=>'The script can\'t write in data/ dir, check permissions set on this folder.'), 'write_error_data'=>array('fr'=>'Le script ne peut pas écrire dans le dossier data/, vérifiez les permissions sur ce dossier.', 'en'=>'The script can\'t write in data/ dir, check permissions set on this folder.'),
'unable_write_config'=>array('fr'=>'Impossible d\'écrire le fichier data/config.php. Vérifiez les permissions.', 'en'=>'Unable to write data/config.php file. Check permissions.'), 'unable_write_config'=>array('fr'=>'Impossible d\'écrire le fichier data/config.php. Vérifiez les permissions.', 'en'=>'Unable to write data/config.php file. Check permissions.'),
'negative_amount'=>array('fr'=>'Montant négatif non autorisé.', 'en'=>'Negative amount not allowed.'), 'negative_amount'=>array('fr'=>'Montant négatif non autorisé.', 'en'=>'Negative amount not allowed.'),
'template_lang_error'=>array('fr'=>'Template non disponible pour la langue choisie. Modifiez les paramètres de langue ou de template.', 'en'=>'Template not available for the selected lang. Change the lang or the template setting.') 'template_error'=>array('fr'=>'Template non disponible.', 'en'=>'Template not available.')
); );
// Include necessary files // Include necessary files
@ -243,14 +243,14 @@
break; break;
case 'settings': case 'settings':
if(!empty($_POST['mysql_host']) && !empty($_POST['mysql_login']) && !empty($_POST['mysql_db']) && !empty($_POST['currency']) && !empty($_POST['instance_title']) && !empty($_POST['base_url']) && !empty($_POST['timezone']) && !empty($_POST['email_webmaster']) && !empty($_POST['template']) && !empty($_POST['lang'])) { if(!empty($_POST['mysql_host']) && !empty($_POST['mysql_login']) && !empty($_POST['mysql_db']) && !empty($_POST['currency']) && !empty($_POST['instance_title']) && !empty($_POST['base_url']) && !empty($_POST['timezone']) && !empty($_POST['email_webmaster']) && !empty($_POST['template'])) {
if(check_token(600, 'settings')) { if(check_token(600, 'settings')) {
if(!is_writable('data/')) { if(!is_writable('data/')) {
$tpl>assign('error', $errors['write_error_data'][LANG]); $tpl>assign('error', $errors['write_error_data'][LANG]);
} }
else { else {
if(!is_dir('tpl/'.$_POST['template'].'_'.$_POST['lang'])) { if(!is_dir('tpl/'.$_POST['template'])) {
$tpl->assign('error', $errors['template_lang_error'][LANG]); $tpl->assign('error', $errors['template_error'][LANG]);
} }
else { else {
$config = file('data/config.php'); $config = file('data/config.php');
@ -275,9 +275,9 @@
elseif(strpos($line, "EMAIL_WEBMASTER") !== FALSE) elseif(strpos($line, "EMAIL_WEBMASTER") !== FALSE)
$config[$line_number] = "\tdefine('EMAIL_WEBMASTER', '".$_POST['email_webmaster']."');\n"; $config[$line_number] = "\tdefine('EMAIL_WEBMASTER', '".$_POST['email_webmaster']."');\n";
elseif(strpos($line, "TEMPLATE_DIR") !== FALSE) elseif(strpos($line, "TEMPLATE_DIR") !== FALSE)
$config[$line_number] = "\tdefine('TEMPLATE_DIR', 'tpl/".$_POST['template']."_".$_POST['lang']."/');\n"; $config[$line_number] = "\tdefine('TEMPLATE_DIR', 'tpl/".$_POST['template']."/');\n";
elseif(strpos($line, "LANG") !== FALSE) elseif(strpos($line, "LANG") !== FALSE)
$config[$line_number] = "\tdefine('LANG', '".$_POST['lang']."');\n"; $config[$line_number] = "\tdefine('LANG', '".substr($_POST['template'], -2)."');\n";
elseif(strpos($line_number, 'date_default_timezone_set') !== FALSE) elseif(strpos($line_number, 'date_default_timezone_set') !== FALSE)
$config[$line_number] = "\tdate_default_timezone_set('".$_POST['timezone']."');\n"; $config[$line_number] = "\tdate_default_timezone_set('".$_POST['timezone']."');\n";
} }

View File

@ -53,17 +53,10 @@
<label for="template">Template : </label> <label for="template">Template : </label>
<select name="template" id="template"> <select name="template" id="template">
{loop="templates"} {loop="templates"}
<option value="{$value}" {if condition="$value == $current_template"} selected="selected" {/if}>{$value}</option> <option value="{$value['value']}" {if condition="$value == $current_template"} selected="selected" {/if}>{$value['option']}</option>
{/loop} {/loop}
</select </select
</p> </p>
<p>
<label for="lang">Lang : </label>
<select name="lang" id="lang">
<option value="en" {if condition="$lang == 'en'"} selected="selected"{/if}>English</option>
<option value="fr" {if condition="$lang == 'fr'"} selected="selected"{/if}>French</option>
</select>
</p>
<p><label for="email_webmaster">Webmaster's email : </label><input type="text" name="email_webmaster" id="email_webmaster" value="{$email_webmaster}"/></p> <p><label for="email_webmaster">Webmaster's email : </label><input type="text" name="email_webmaster" id="email_webmaster" value="{$email_webmaster}"/></p>
</fieldset> </fieldset>
<p class="center"><input type="submit" value="Update settings"><input type="hidden" name="token" value="{$token}"/></p> <p class="center"><input type="submit" value="Update settings"><input type="hidden" name="token" value="{$token}"/></p>