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); } ?>