i18n
authorPierre Habouzit <madcoder@debian.org>
Wed, 10 Sep 2003 16:28:24 +0000 (16:28 +0000)
committerPierre Habouzit <madcoder@debian.org>
Wed, 10 Sep 2003 16:28:24 +0000 (16:28 +0000)
philter/philter/include/emails.inc.php
philter/philter/include/js_factory.inc.php
philter/philter/include/philter.inc.php
philter/philter/include/plugin_autoreply.inc.php
philter/philter/include/plugin_forward.inc.php
philter/philter/index.php
philter/philter/install.d/config.inc.php
philter/philter/locales/philter.en.inc.php
philter/philter/locales/plugins/autoreply.en.inc.php [new file with mode: 0644]
philter/philter/locales/plugins/forward.en.inc.php [new file with mode: 0644]
philter/philter/philter.js

index 4ef2277..7c302f8 100644 (file)
@@ -97,10 +97,11 @@ class EmailPool {
      * @return  the string containing the form
      */
     function to_form() {
+        global $philter;
         $res = "<form id=\"emails\" action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n"
             .  "<table class=\"bicol\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\" align=\"center\">\n"
-            .  "<tr><th>Email</th>\n"
-            .  "    <th>Active</th>\n"
+            .  "<tr><th>".$philter->i18n('email')."</th>\n"
+            .  "    <th>".$philter->i18n('active')."</th>\n"
             .  "    <th>&nbsp;</th>\n"
             .  "</tr>\n";
 
@@ -121,16 +122,18 @@ class EmailPool {
         $res .= "</table>\n"
             .   "<center>\n"
             .   "    <input id=\"emailsDel\" type=\"hidden\" name=\"emails[del]\" value=\"-1\" />\n"
-            .   "    <input type=\"submit\" name=\"emails[apply]\" value=\"Apply changes\" />\n"
+            .   "    <input type=\"submit\" name=\"emails[apply]\" value=\""
+            .   $philter->i18n('apply_changes')."\" />\n"
             .   "</center>\n"
             .   "</form>\n";
 
-        $val = 'your email ...';
+        $val = $philter->i18n('your_email');
         
         $res .= "<form action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n"
             .   "<input type=\"text\" name=\"emails[new]\" size=\"50\" value='$val' "
             .   "    onfocus=\"text_onfocus(this,'$val')\" onblur=\"text_onblur(this,'$val')\" />\n"
-            .   "<input type=\"submit\" name=\"emails[add]\" value=\"Add\" />\n"
+            .   "<input type=\"submit\" name=\"emails[add]\" value=\"".
+                $philter->i18n('add')."\" />\n"
             .   "</form>\n";
         
         return $res;
index 612cf49..71bbb9f 100644 (file)
 <script language="javascript1.3" type="text/javascript">
 <?php
 
+/********** i18n **********/
+
+echo "del_i18n = '"._i18n('del')."';\n";
+echo "del_q_i18n = '"._i18n('del_email_q')."';\n";
+
 /********** mail_pool **********/
 echo $mail_pool->to_js();
 
index 8874dcd..0196f66 100644 (file)
@@ -10,6 +10,7 @@
 require_once("include/core.inc.php");
 
 function i18n($_index) { global $philter; echo $philter->i18n($_index); }
+function _i18n($_index) { global $philter; return $philter->i18n($_index); }
 
 /** Philter base configuration class
  * This is the base class of Philter.
index 671d7a0..c1924aa 100644 (file)
@@ -10,7 +10,7 @@
 class AutoReplyPlugin extends ActionPlugin {
     function FwdPlugin() { $this->ActionPlugin(); }
     function rtti() { return 2; }
-    function name() { return "Auto-Reply"; }
+    function name() { return _i18n('2_auto_reply'); }
 
     function to_js() {
         $res  = "function(Node, data) {\n"
@@ -22,7 +22,7 @@ class AutoReplyPlugin extends ActionPlugin {
             .   "    if(data[1]) ta.value = data[1];\n"
             .   "\n"
             .   "    Node.appendChild(document.createElement('br'));\n"
-            .   "    Node.appendChild(document.createTextNode(' Your mail : '));\n"
+            .   "    Node.appendChild(document.createTextNode('"._i18n('2_your_mail')."'));\n"
             .   "    Node.appendChild(document.createElement('br'));\n"
             .   "    Node.appendChild(ta);\n"
             .   "}";
index 2b0617a..a0b5c83 100644 (file)
@@ -10,7 +10,7 @@
 class FwdPlugin extends ActionPlugin {
     function FwdPlugin() { $this->ActionPlugin(); }
     function rtti() { return 1; }
-    function name() { return "Forward To"; }
+    function name() { return _i18n('1_fwd_to'); }
 
     function to_js() {
         $res  = "function(Node, data) {\n"
@@ -19,7 +19,7 @@ class FwdPlugin extends ActionPlugin {
             .   "    var select = document.createElement('select');\n"
             .   "    select.setAttribute('name', Node.name+'[1]');\n"
             .   "\n"
-            .   "    Node.appendChild(document.createTextNode(' email : '));\n"
+            .   "    Node.appendChild(document.createTextNode('"._i18n('1_email')."'));\n"
             // OG: must insert select node before creating options because of IE5 bug
             .   "    Node.appendChild(select);\n"
             .   "\n"
index bdddba1..0ba4f99 100644 (file)
@@ -39,8 +39,7 @@ require("include/js_factory.inc.php");
 
 /********** globals plugins **********/
 ?>
-<div class="rubrique">The global configuration
-</div>
+<div class="rubrique"><?php i18n('global_title'); ?></div>
 <?php
 if(count($philter->config['global_plugin'])) {
     echo "<form action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n"
@@ -60,8 +59,7 @@ if(count($philter->config['global_plugin'])) {
 /********** emails **********/
 ?>
 <br />
-<div class="rubrique">The redirection address pool
-</div>
+<div class="rubrique"><?php i18n('pool_title'); ?></div>
 <?php
 echo $mail_pool->to_form();
 
@@ -69,13 +67,12 @@ echo $mail_pool->to_form();
 ?>
 
 <br />
-<div class="rubrique">The individuals rules
-</div>
+<div class="rubrique"><?php i18n('filter_title'); ?></div>
 <table width="95%" cellspacing="0" cellpadding="2" align="center">
 <tr><td width="25%" valign="top">
         <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;">
         <table class="bicol" width="100%" cellpadding="1" cellspacing="1">
-        <tr><th>Filter List</th></tr>
+        <tr><th><?php i18n('filter_list_title');?></th></tr>
         <tr><td>
 <?php
             foreach($filter->rules as $id=>$rule)
@@ -85,8 +82,9 @@ echo $mail_pool->to_form();
                         : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0));
                 
             echo "<select size=\"16\" style=\"width:100%;\" id=\"orderSelect\" name=\"order[select]\" onchange=\"createRuleForm()\">\n";
-            echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"")
-                .">[ new rule ]</option>\n";
+            echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"").">";
+            i18n('new_rule');
+            echo "</option>\n";
             
             foreach($filter->rules as $id=>$rule)
                 echo "<option value=\"$id\""
@@ -95,10 +93,10 @@ echo $mail_pool->to_form();
 ?>
             </select>
         </td></tr><tr><td>
-            <input type="submit" value="Up" name="order[up]" onclick="order_up();" />
-            <input type="submit" value="Down" name="order[dn]" onclick="order_dn();" /><br />
-            <input type="submit" value="Delete" name="order[delete]" onclick="order_submit(this)" />
-            <input type="submit" value="Submit" name="order[submit]" onclick="order_submit(this)" />
+            <input type="submit" value="<?php i18n('up');?>" name="order[up]" onclick="order_up();" />
+            <input type="submit" value="<?php i18n('dn');?>" name="order[dn]" onclick="order_dn();" /><br />
+            <input type="submit" value="<?php i18n('del');?>" name="order[delete]" onclick="order_submit(this)" />
+            <input type="submit" value="<?php i18n('submit');?>" name="order[submit]" onclick="order_submit(this)" />
             <input type="hidden" value="" name="order[action]" />
         </td></tr>
         </table>
@@ -107,25 +105,27 @@ echo $mail_pool->to_form();
     <td valign="top">
         <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;">
         <table width="100%" class="bicol" cellspacing="1" cellpadding="1">
-        <tr class="impair"><th>Rule Configuration
+        <tr class="impair"><th><?php i18n('filter_rule_conf');?>
         </th></tr><tr class="impair"><td>
             <input type="hidden" value="0" id="ruleId" name="rule[id]" />
             Name of this rule :
             <input type="text" size="60" value="" id="ruleName" name="rule[name]"
-                onfocus="text_onfocus(this,'[ new rule ]')" onblur="text_onblur(this,'[ new rule ]')" />
+                onfocus="text_onfocus(this,'<?php i18n('new_rule');?>')"
+                onblur="text_onblur(this,'<?php i18n('new_rule');?>')" />
             <br />
-            <input type="radio" value="1" id="ruleAll1" name="rule[all]" />All matches
-            <input type="radio" value="0" id="ruleAll0" name="rule[all]" />One match
+            <input type="radio" value="1" id="ruleAll1" name="rule[all]" /><?php i18n('all_matches');?>
+            <input type="radio" value="0" id="ruleAll0" name="rule[all]" /><?php i18n('one_match');?>
             <br />
-            <input type="checkbox" checked="checked" id="ruleBlock" name="rule[block]" />Blocking Rule
-        </td></tr><tr class="impair"><th>Matches List
+            <input type="checkbox" checked="checked" id="ruleBlock" name="rule[block]" />
+            <?php i18n('blocking_rule');?>
+        </td></tr><tr class="impair"><th><?php i18n('filter_matches_list');?>
         </th></tr><tr class="impair"><td id="matchesRow">
-        </td></tr><tr class="impair"><th>Actions List
+        </td></tr><tr class="impair"><th><?php i18n('filter_actions_list');?>
         </th></tr><tr class="impair"><td id="actionsRow">
         </td></tr><tr class="impair"><td>
-            <input type="submit" value="New Match" name="rule[new_match]" onclick="newMatch() "/>
-            <input type="submit" value="New Action" name="rule[new_action]" onclick="newAction()" />
-            <input type="submit" value="Submit" name="rule[submit]" onclick="this.form.submit()" />
+            <input type="submit" value="<?php i18n('new_match');?>" name="rule[new_match]" onclick="newMatch() "/>
+            <input type="submit" value="<?php i18n('new_action');?>" name="rule[new_action]" onclick="newAction()" />
+            <input type="submit" value="<?php i18n('submit');?>" name="rule[submit]" onclick="this.form.submit()" />
         </td></tr>
         </table>
         </form>
index fb2f1c8..4ba27be 100644 (file)
@@ -9,6 +9,10 @@
 
 $philter = new Philter();
 
+/********** LOCALE **********/
+
+require("locales/philter.en.inc.php");
+
 /********** DATABASE **********/
 
 $philter->config['db']['host'] = "localhost";
index b5ad432..18a0663 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 /********************************************************************************
-* include/core.inc.php : The include file for using Philter Core
-* --------------------
+* i18n file
 *
 * This file is part of the philter distribution
 * Copyright: See COPYING files that comes with this distribution
@@ -14,6 +13,8 @@ $philter->config['i18n'] = Array(
     'del' => 'Delete',
     'submit' => 'Submit',
 
+    'del_email_q' => 'Do you really want to delete this email address ?',
+
     'new_action' => 'New Action',
     'new_match' => 'New Match',
         
@@ -41,12 +42,12 @@ $philter->config['i18n'] = Array(
     'add' => 'Add'
 );
 
-$handle = opendir('locales/plugins');
+
+$handle = opendir('locales/plugins/');
 while(($file = readdir($handle)) !== false)
     if(preg_match("/^.*\.en\.inc\.php$/",$file))
-        require_once('include/plugins/'.$file);
+        require_once('locales/plugins/'.$file);
 closedir($handle);
-
 // PHP 4.3.0 required !!!
 // foreach(glob("include/plugins/*.en.inc.php") as $file) require_once($file);
 
diff --git a/philter/philter/locales/plugins/autoreply.en.inc.php b/philter/philter/locales/plugins/autoreply.en.inc.php
new file mode 100644 (file)
index 0000000..3a55722
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/********************************************************************************
+* i18n file
+*
+* This file is part of the philter distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+$philter->config['i18n']['2_auto_reply'] = 'Auto-Reply';
+$philter->config['i18n']['2_your_mail'] = ' Your mail : ';
+
+/********************************************************************************
+* $Id$
+* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
+********************************************************************************/
+?>
diff --git a/philter/philter/locales/plugins/forward.en.inc.php b/philter/philter/locales/plugins/forward.en.inc.php
new file mode 100644 (file)
index 0000000..5b9dcf2
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/********************************************************************************
+* i18n file
+*
+* This file is part of the philter distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+$philter->config['i18n']['1_fwd_to'] = 'Forward To';
+$philter->config['i18n']['1_email'] = ' email : ';
+
+/********************************************************************************
+* $Id$
+* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
+********************************************************************************/
+?>
index 7ce229e..30b573b 100644 (file)
@@ -30,7 +30,7 @@ function getElement(obj) {
 }
 
 function del_onclick(val) {
-    if(window.confirm("Do you really want to delete this email address ?")) {
+    if(window.confirm(del_q_i18n)) {
         getElement('emailsDel').value = val;
         document.forms['emails'].submit();
     }
@@ -102,6 +102,9 @@ var current_rule;
 var actions_i = 0;
 var matches_i = 0;
 
+var del_i18n = 'Del';
+var del_q_i18n = 'Del';
+
 /********** RULE.ACTION FORM FUNCTIONS **********/
 
 function createActionSelect(div,data) {
@@ -131,7 +134,7 @@ function createActionRow(Node,data) {
 
     var del = document.createElement("input");
     del.setAttribute("type", "submit");
-    del.setAttribute("value", "Del");
+    del.setAttribute("value", del_i18n);
     del.onclick = function () { del.parentNode.parentNode.removeChild(del.parentNode); };
     div.appendChild(del);
 
@@ -175,7 +178,7 @@ function createMatchRow(Node,data) {
 
     var del = document.createElement("input");
     del.setAttribute("type", "submit");
-    del.setAttribute("value", "Del");
+    del.setAttribute("value", del_i18n);
     del.onclick = function () { del.parentNode.parentNode.removeChild(del.parentNode); };
     div.appendChild(del);