[Mapbender-commits] r3917 - in branches/translationBuilder: . http
http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Apr 30 10:05:48 EDT 2009
Author: saith
Date: 2009-04-30 10:05:48 -0400 (Thu, 30 Apr 2009)
New Revision: 3917
Added:
branches/translationBuilder/admin_div_de.sql
branches/translationBuilder/http/
branches/translationBuilder/http/php/
branches/translationBuilder/http/php/mb_translationbuilder.js
branches/translationBuilder/http/php/mb_translationbuilder_div.php
branches/translationBuilder/http/php/mb_translationbuilder_sql.php
branches/translationBuilder/isocodes.sql
Log:
translationBuilder
Added: branches/translationBuilder/admin_div_de.sql
===================================================================
--- branches/translationBuilder/admin_div_de.sql (rev 0)
+++ branches/translationBuilder/admin_div_de.sql 2009-04-30 14:05:48 UTC (rev 3917)
@@ -0,0 +1,4 @@
+INSERT INTO gui (gui_id, gui_name, gui_description, gui_public) VALUES ('admin_div_de','admin_div_de','admin GUI in deutscher Sprache',1);
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('admin_div_de','AdminDiv',2,1,'the div for administration modules','','div','','',200,20,800,800,NULL ,'','','div','','','','','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('admin_div_de','body',1,1,'navigation','','body','','onload="init()"',0,0,NULL ,NULL ,NULL ,'','','','mod_adminNavigation.js','','','','');
+INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('admin_div_de','translationbuilder_div',2,1,'Übersetzung','Translation Builder','a','','',8,10,190,20,5,'','Übersetzung','a','mod_translationBuilder_div.php','','','','http://www.mapbender.org/index.php/user');
\ No newline at end of file
Added: branches/translationBuilder/http/php/mb_translationbuilder.js
===================================================================
--- branches/translationBuilder/http/php/mb_translationbuilder.js (rev 0)
+++ branches/translationBuilder/http/php/mb_translationbuilder.js 2009-04-30 14:05:48 UTC (rev 3917)
@@ -0,0 +1,64 @@
+ var count=0;
+ var iso;
+
+ function isodbselect(){
+ iso = document.form1.isoselect.value;
+ if (iso != "empty") {
+
+ var req = new parent.Mapbender.Ajax.Request({
+ "method" : "isoselect",
+ "parameters" : {
+ "locale" : iso
+ }
+ });
+ req.send("../php/mb_translationbuilder_sql.php", function(jsonObj, result, message) {
+ document.getElementById("transTable").innerHTML = displayTable(jsonObj);
+ alert(message);
+ }
+ );
+ } else {
+ document.getElementById("transTable").innerHTML = "Please select a language."
+ }
+ }
+
+ function displayTable(obj){
+ count=0;
+ var text = "<form name=\"form2\" action=\"\" method=\"post\"><table><tr><th>English</th><th>Translation</th></tr>";
+ for (var attr in obj) {
+ var resultObj = obj[attr];
+ text += "<tr><td><input type=\"text\" value=\"" + resultObj.msgid +
+ "\" readonly /></td><td><input type=\"text\" id=\"trs" + attr + "\" name=\"" + resultObj.msgid +
+ "\" value=\"" + resultObj.msgstr + "\" /></td></tr>";
+ count++;
+ }
+ text += "<tr><td align=\"right\"><input type=\"button\" value=\"Translate\" name=\"translatebutton\" onclick=\"return translate()\" /></td>" +
+ "<td><input type=\"reset\" value=\"Reset\" name=\"resetbutton\" /></td></tr>";
+ text += "</table></form>";
+ return text;
+ }
+
+ function translate(){
+ iso = document.form1.isoselect.value;
+
+ var translate_array = [];
+ for (var i = 0; i < count; i++){
+ translate_array[i] = {
+ "msgid" : document.getElementById("trs" + i).name,
+ "msgstr" : document.getElementById("trs" + i).value
+ };
+ }
+
+ var req = new parent.Mapbender.Ajax.Request({
+ "method" : "translate",
+ "parameters" : {
+ "locale" : iso,
+ "translations" : translate_array
+ }
+ });
+
+ req.send("../php/mb_translationbuilder_sql.php", function(jsonObj, result, message) {
+ isodbselect();
+ }
+ );
+
+ }
\ No newline at end of file
Added: branches/translationBuilder/http/php/mb_translationbuilder_div.php
===================================================================
--- branches/translationBuilder/http/php/mb_translationbuilder_div.php (rev 0)
+++ branches/translationBuilder/http/php/mb_translationbuilder_div.php 2009-04-30 14:05:48 UTC (rev 3917)
@@ -0,0 +1,68 @@
+<?php
+# $Id: mod_translationbuilder.php
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import_request_variables("PG");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+require_once(dirname(__FILE__) . "/../../conf/mapbender.conf");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="cache-control" content="no-cache">
+ <meta http-equiv="pragma" content="no-cache">
+ <meta http-equiv="expires" content="0">
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>">
+ <title>Translation_Builder</title>
+ <script type="text/javascript" src="mb_translationbuilder.js"></script>
+ </head>
+ <body>
+
+ <?php
+ # ISO-Codes -> Select-Box
+ $sql = "SELECT iso_code, language FROM iso_codes ORDER BY language ASC";
+ $v = array();
+ $t = array();
+ $res = db_prep_query($sql,$v,$t);
+ ?>
+
+ <form name='form1' action='' method='post'>
+ <table class='table_top'>
+ <tr><td>
+ <select name='isoselect' onchange='isodbselect()'>
+ <option value='empty' selected='selected'>Please select a language</option>
+ <?php
+ while($row = db_fetch_array($res)){
+ echo "<option value='".$row["iso_code"]."'>".$row["language"]." (".$row["iso_code"].")</option>";
+ }
+ ?>
+ </select>
+ </td>
+ <td><div class='button'><input type='button' value='Select' name='isobutton' onclick='isodbselect()'></div>
+ </table>
+ </form>
+
+ <!--Translations from selected ISO-Code-->
+
+ <div id='transTable' class='result'></div>
+
+ </body>
+</html>
\ No newline at end of file
Added: branches/translationBuilder/http/php/mb_translationbuilder_sql.php
===================================================================
--- branches/translationBuilder/http/php/mb_translationbuilder_sql.php (rev 0)
+++ branches/translationBuilder/http/php/mb_translationbuilder_sql.php 2009-04-30 14:05:48 UTC (rev 3917)
@@ -0,0 +1,96 @@
+<?php
+# $Id:
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+
+# SQL abfragen und return
+
+$ajaxResponse = new AjaxResponse($_REQUEST);
+$command = $ajaxResponse->getMethod();
+$iso_code = $ajaxResponse->getParameter("locale");
+
+if ($command == "isoselect") {
+ isoselect($iso_code);
+}
+
+function isoselect($iso_code) {
+ global $ajaxResponse;
+
+ $flag=false;
+
+ #is selected language in translations
+ $sql = "SELECT locale FROM translations WHERE locale = '". $iso_code ."'";
+ $v = array();
+ $t = array();
+ $res = db_prep_query($sql,$v,$t);
+
+ while ($row = db_fetch_array($res)){
+ if ($row["locale"]==$iso_code) { $flag = true; }
+ }
+
+ if ($flag==false) {
+ $sql = "INSERT INTO translations( locale, msgid, msgstr ) SELECT '". $iso_code ."' AS locale, msgid, msgid as msgstr FROM translations WHERE locale = 'DE'";
+ $v = array();
+ $t = array();
+ $res = db_prep_query($sql,$v,$t);
+ }
+
+ #select translations for selected language
+ $localeObj = array();
+ $sql = "SELECT trs_id,locale,msgid,msgstr FROM translations WHERE locale = '". $iso_code ."' ORDER BY trs_id ASC";
+ $v = array();
+ $t = array();
+ $res = db_prep_query($sql,$v,$t);
+
+ while($row = db_fetch_array($res)){
+ array_push($localeObj, array(
+ "trs_id" => $row["trs_id"],
+ "locale" => $row["locale"],
+ "msgid" => $row["msgid"],
+ "msgstr" => $row["msgstr"]
+ ));
+ }
+
+ if ($flag == false) {
+ $message = "No translation found in database. New translation created.";
+ } else {
+ $message = "Successfully loaded translation from database.";
+ }
+
+ $ajaxResponse->setMessage($message);
+ $ajaxResponse->setResult($localeObj);
+ $ajaxResponse->send();
+}
+
+if ($command == "translate") {
+$translations = $ajaxResponse->getParameter("translations");
+$count = count($translations);
+$datei = fopen(dirname(__FILE__)."/../tmp/translation_". $iso_code . ".sql", "w");
+ for ($i=0; $i < $count; $i++) {
+ $sql = "UPDATE translations SET msgstr = '" . $translations[$i]->msgstr . "' WHERE msgid = '". $translations[$i]->msgid . "' and locale = '" . $iso_code . "';";
+ fwrite($datei, "INSERT INTO translations (locale , msgid, msgstr ) VALUES ('" . $iso_code . "', '" . $translations[$i]->msgid . "', '" . $translations[$i]->msgstr . "');\n");
+ $v = array();
+ $t = array();
+ $res = db_prep_query($sql,$v,$t);
+ }
+fclose($datei);
+isoselect($iso_code);
+}
+?>
Added: branches/translationBuilder/isocodes.sql
===================================================================
--- branches/translationBuilder/isocodes.sql (rev 0)
+++ branches/translationBuilder/isocodes.sql 2009-04-30 14:05:48 UTC (rev 3917)
@@ -0,0 +1,155 @@
+UPDATE translations SET locale='gr' WHERE locale='gr ';
+
+UPDATE translations SET locale='BG' WHERE locale='bg';
+UPDATE translations SET locale='DE' WHERE locale='de';
+UPDATE translations SET locale='ES' WHERE locale='es';
+UPDATE translations SET locale='EL' WHERE locale='gr';
+UPDATE translations SET locale='FR' WHERE locale='fr';
+UPDATE translations SET locale='IT' WHERE locale='it';
+UPDATE translations SET locale='NL' WHERE locale='nl';
+UPDATE translations SET locale='PT' WHERE locale='pt';
+
+CREATE TABLE iso_codes
+(
+ iso_code varchar,
+ language varchar
+) WITH OIDS;
+
+#http://www.w3.org/WAI/ER/IG/ert/iso639.htm
+
+INSERT INTO iso_codes VALUES ('AA', 'Afar');
+INSERT INTO iso_codes VALUES ('AB', 'Abkhazian');
+INSERT INTO iso_codes VALUES ('AF', 'Afrikaans');
+INSERT INTO iso_codes VALUES ('AM', 'Amharic');
+INSERT INTO iso_codes VALUES ('AR', 'Arabic');
+INSERT INTO iso_codes VALUES ('AS', 'Assamese');
+INSERT INTO iso_codes VALUES ('AY', 'Aymara');
+INSERT INTO iso_codes VALUES ('AZ', 'Azerbaijani');
+INSERT INTO iso_codes VALUES ('BA', 'Bashkir');
+INSERT INTO iso_codes VALUES ('BE', 'Byelorussian');
+INSERT INTO iso_codes VALUES ('BG', 'Bulgarian');
+INSERT INTO iso_codes VALUES ('BH', 'Bihari');
+INSERT INTO iso_codes VALUES ('BI', 'Bislama');
+INSERT INTO iso_codes VALUES ('BN', 'Bengali');
+INSERT INTO iso_codes VALUES ('BO', 'Tibetan');
+INSERT INTO iso_codes VALUES ('BR', 'Breton');
+INSERT INTO iso_codes VALUES ('CA', 'Catalan');
+INSERT INTO iso_codes VALUES ('CO', 'Corsican');
+INSERT INTO iso_codes VALUES ('CS', 'Czech');
+INSERT INTO iso_codes VALUES ('CY', 'Welsh');
+INSERT INTO iso_codes VALUES ('DA', 'Danish');
+INSERT INTO iso_codes VALUES ('DE', 'German');
+INSERT INTO iso_codes VALUES ('DZ', 'Bhutani');
+INSERT INTO iso_codes VALUES ('EL', 'Greek');
+INSERT INTO iso_codes VALUES ('EN', 'English');
+INSERT INTO iso_codes VALUES ('EO', 'Esperanto');
+INSERT INTO iso_codes VALUES ('ES', 'Spanish');
+INSERT INTO iso_codes VALUES ('ET', 'Estonian');
+INSERT INTO iso_codes VALUES ('EU', 'Basque');
+INSERT INTO iso_codes VALUES ('FA', 'Persian');
+INSERT INTO iso_codes VALUES ('FI', 'Finnish');
+INSERT INTO iso_codes VALUES ('FJ', 'Fiji');
+INSERT INTO iso_codes VALUES ('FO', 'Faeroese');
+INSERT INTO iso_codes VALUES ('FR', 'French');
+INSERT INTO iso_codes VALUES ('FY', 'Frisian');
+INSERT INTO iso_codes VALUES ('GA', 'Irish');
+INSERT INTO iso_codes VALUES ('GD', 'Gaelic');
+INSERT INTO iso_codes VALUES ('GL', 'Galician');
+INSERT INTO iso_codes VALUES ('GN', 'Guarani');
+INSERT INTO iso_codes VALUES ('GU', 'Gujarati');
+INSERT INTO iso_codes VALUES ('HA', 'Hausa');
+INSERT INTO iso_codes VALUES ('HI', 'Hindi');
+INSERT INTO iso_codes VALUES ('HR', 'Croatian');
+INSERT INTO iso_codes VALUES ('HU', 'Hungarian');
+INSERT INTO iso_codes VALUES ('HY', 'Armenian');
+INSERT INTO iso_codes VALUES ('IA', 'Interlingua');
+INSERT INTO iso_codes VALUES ('IE', 'Interlingue');
+INSERT INTO iso_codes VALUES ('IK', 'Inupiak');
+INSERT INTO iso_codes VALUES ('IN', 'Indonesian');
+INSERT INTO iso_codes VALUES ('IS', 'Icelandic');
+INSERT INTO iso_codes VALUES ('IT', 'Italian');
+INSERT INTO iso_codes VALUES ('IW', 'Hebrew');
+INSERT INTO iso_codes VALUES ('JA', 'Japanese');
+INSERT INTO iso_codes VALUES ('JI', 'Yiddish');
+INSERT INTO iso_codes VALUES ('JW', 'Javanese');
+INSERT INTO iso_codes VALUES ('KA', 'Georgian');
+INSERT INTO iso_codes VALUES ('KK', 'Kazakh');
+INSERT INTO iso_codes VALUES ('KL', 'Greenlandic');
+INSERT INTO iso_codes VALUES ('KM', 'Cambodian');
+INSERT INTO iso_codes VALUES ('KN', 'Kannada');
+INSERT INTO iso_codes VALUES ('KO', 'Korean');
+INSERT INTO iso_codes VALUES ('KS', 'Kashmiri');
+INSERT INTO iso_codes VALUES ('KU', 'Kurdish');
+INSERT INTO iso_codes VALUES ('KY', 'Kirghiz');
+INSERT INTO iso_codes VALUES ('LA', 'Latin');
+INSERT INTO iso_codes VALUES ('LN', 'Lingala');
+INSERT INTO iso_codes VALUES ('LO', 'Laothian');
+INSERT INTO iso_codes VALUES ('LT', 'Lithuanian');
+INSERT INTO iso_codes VALUES ('LV', 'Latvian');
+INSERT INTO iso_codes VALUES ('MG', 'Malagasy');
+INSERT INTO iso_codes VALUES ('MI', 'Maori');
+INSERT INTO iso_codes VALUES ('MK', 'Macedonian');
+INSERT INTO iso_codes VALUES ('ML', 'Malayalam');
+INSERT INTO iso_codes VALUES ('MN', 'Mongolian');
+INSERT INTO iso_codes VALUES ('MO', 'Moldavian');
+INSERT INTO iso_codes VALUES ('MR', 'Marathi');
+INSERT INTO iso_codes VALUES ('MS', 'Malay');
+INSERT INTO iso_codes VALUES ('MT', 'Maltese');
+INSERT INTO iso_codes VALUES ('MY', 'Burmese');
+INSERT INTO iso_codes VALUES ('NA', 'Nauru');
+INSERT INTO iso_codes VALUES ('NE', 'Nepali');
+INSERT INTO iso_codes VALUES ('NL', 'Dutch');
+INSERT INTO iso_codes VALUES ('NO', 'Norwegian');
+INSERT INTO iso_codes VALUES ('OC', 'Occitan');
+INSERT INTO iso_codes VALUES ('OM', 'Oromo');
+INSERT INTO iso_codes VALUES ('OR', 'Oriya');
+INSERT INTO iso_codes VALUES ('PA', 'Punjabi');
+INSERT INTO iso_codes VALUES ('PL', 'Polish');
+INSERT INTO iso_codes VALUES ('PS', 'Pashto');
+INSERT INTO iso_codes VALUES ('PT', 'Portuguese');
+INSERT INTO iso_codes VALUES ('QU', 'Quechua');
+INSERT INTO iso_codes VALUES ('RM', 'Rhaeto-Romance');
+INSERT INTO iso_codes VALUES ('RN', 'Kirundi');
+INSERT INTO iso_codes VALUES ('RO', 'Romanian');
+INSERT INTO iso_codes VALUES ('RU', 'Russian');
+INSERT INTO iso_codes VALUES ('RW', 'Kinyarwanda');
+INSERT INTO iso_codes VALUES ('SA', 'Sanskrit');
+INSERT INTO iso_codes VALUES ('SD', 'Sindhi');
+INSERT INTO iso_codes VALUES ('SG', 'Sangro');
+INSERT INTO iso_codes VALUES ('SH', 'Serbo-Croatian');
+INSERT INTO iso_codes VALUES ('SI', 'Singhalese');
+INSERT INTO iso_codes VALUES ('SK', 'Slovak');
+INSERT INTO iso_codes VALUES ('SL', 'Slovenian');
+INSERT INTO iso_codes VALUES ('SM', 'Samoan');
+INSERT INTO iso_codes VALUES ('SN', 'Shona');
+INSERT INTO iso_codes VALUES ('SO', 'Somali');
+INSERT INTO iso_codes VALUES ('SQ', 'Albanian');
+INSERT INTO iso_codes VALUES ('SR', 'Serbian');
+INSERT INTO iso_codes VALUES ('SS', 'Siswati');
+INSERT INTO iso_codes VALUES ('ST', 'Sesotho');
+INSERT INTO iso_codes VALUES ('SU', 'Sudanese');
+INSERT INTO iso_codes VALUES ('SV', 'Swedish');
+INSERT INTO iso_codes VALUES ('SW', 'Swahili');
+INSERT INTO iso_codes VALUES ('TA', 'Tamil');
+INSERT INTO iso_codes VALUES ('TE', 'Tegulu');
+INSERT INTO iso_codes VALUES ('TG', 'Tajik');
+INSERT INTO iso_codes VALUES ('TH', 'Thai');
+INSERT INTO iso_codes VALUES ('TI', 'Tigrinya');
+INSERT INTO iso_codes VALUES ('TK', 'Turkmen');
+INSERT INTO iso_codes VALUES ('TL', 'Tagalog');
+INSERT INTO iso_codes VALUES ('TN', 'Setswana');
+INSERT INTO iso_codes VALUES ('TO', 'Tonga');
+INSERT INTO iso_codes VALUES ('TR', 'Turkish');
+INSERT INTO iso_codes VALUES ('TS', 'Tsonga');
+INSERT INTO iso_codes VALUES ('TT', 'Tatar');
+INSERT INTO iso_codes VALUES ('TW', 'Twi');
+INSERT INTO iso_codes VALUES ('UK', 'Ukrainian');
+INSERT INTO iso_codes VALUES ('UR', 'Urdu');
+INSERT INTO iso_codes VALUES ('UZ', 'Uzbek');
+INSERT INTO iso_codes VALUES ('VI', 'Vietnamese');
+INSERT INTO iso_codes VALUES ('VO', 'Volapuk');
+INSERT INTO iso_codes VALUES ('WO', 'Wolof');
+INSERT INTO iso_codes VALUES ('XH', 'Xhosa');
+INSERT INTO iso_codes VALUES ('YO', 'Yoruba');
+INSERT INTO iso_codes VALUES ('ZH', 'Chinese');
+INSERT INTO iso_codes VALUES ('ZU', 'Zulu');
More information about the Mapbender_commits
mailing list