function translate($indata, $namespace = FALSE)
{
    if (getsetting("enabletranslation", true) == false) {
        return $indata;
    }
    global $session, $translation_table, $translation_namespace;
    if (!$namespace) {
        $namespace = $translation_namespace;
    }
    $outdata = $indata;
    if (!isset($namespace) || $namespace == "") {
        tlschema();
    }
    $foundtranslation = false;
    if ($namespace != "notranslate") {
        if (!isset($translation_table[$namespace]) || !is_array($translation_table[$namespace])) {
            //build translation table for this page hit.
            $translation_table[$namespace] = translate_loadnamespace($namespace, isset($session['tlanguage']) ? $session['tlanguage'] : false);
        }
    }
    if (is_array($indata)) {
        //recursive translation on arrays.
        $outdata = array();
        while (list($key, $val) = each($indata)) {
            $outdata[$key] = translate($val, $namespace);
        }
    } else {
        if ($namespace != "notranslate") {
            if (isset($translation_table[$namespace][$indata])) {
                $outdata = $translation_table[$namespace][$indata];
                $foundtranslation = true;
                // Remove this from the untranslated texts table if it is
                // in there and we are collecting texts
                // This delete is horrible on very heavily translated games.
                // It has been requested to be removed.
                /*
                if (getsetting("collecttexts", false)) {
                	$sql = "DELETE FROM " . db_prefix("untranslated") .
                		" WHERE intext='" . addslashes($indata) .
                		"' AND language='" . LANGUAGE . "'";
                	db_query($sql);
                }
                */
            } elseif (getsetting("collecttexts", false)) {
                $sql = "INSERT IGNORE INTO " . db_prefix("untranslated") . " (intext,language,namespace) VALUES ('" . addslashes($indata) . "', '" . LANGUAGE . "', " . "'{$namespace}')";
                db_query($sql, false);
            }
            tlbutton_push($indata, !$foundtranslation, $namespace);
        } else {
            $outdata = $indata;
        }
    }
    return $outdata;
}
function translate($indata, $namespace = FALSE)
{
    if (getsetting("enabletranslation", true) == false) {
        return $indata;
    }
    global $session, $translation_table, $translation_namespace;
    if (!$namespace) {
        $namespace = $translation_namespace;
    }
    $outdata = $indata;
    if (!isset($namespace) || $namespace == "") {
        tlschema();
    }
    $foundtranslation = false;
    if ($namespace != "notranslate") {
        if (!isset($translation_table[$namespace]) || !is_array($translation_table[$namespace])) {
            //build translation table for this page hit.
            $translation_table[$namespace] = translate_loadnamespace($namespace, isset($session['tlanguage']) ? $session['tlanguage'] : false);
        }
    }
    if (is_array($indata)) {
        //recursive translation on arrays.
        $outdata = array();
        while (list($key, $val) = each($indata)) {
            $outdata[$key] = translate($val, $namespace);
        }
    } else {
        if ($namespace != "notranslate") {
            if (isset($translation_table[$namespace][$indata])) {
                //tweak to keep track of most commonly-used translations, for removal and reassignment
                // $sql = "UPDATE ".db_prefix("translations")." SET version = 'checked' WHERE uri = '$namespace' AND intext='$indata' AND intext != outtext AND version != 'checked'";
                // db_query($sql);
                $outdata = $translation_table[$namespace][$indata];
                $foundtranslation = true;
            } elseif (getsetting("collecttexts", false)) {
                $sql = "INSERT IGNORE INTO " . db_prefix("untranslated") . " (intext,language,namespace) VALUES ('" . addslashes($indata) . "', '" . LANGUAGE . "', " . "'{$namespace}')";
                db_query($sql, false);
            }
            tlbutton_push($indata, !$foundtranslation, $namespace);
        } else {
            $outdata = $indata;
        }
    }
    return $outdata;
}
<?php

// addnews ready
// translator ready
// mail ready
define("OVERRIDE_FORCED_NAV", true);
require_once "common.php";
tlschema("translatortool");
check_su_access(SU_IS_TRANSLATOR);
$op = httpget("op");
if ($op == "") {
    popup_header("Translator Tool");
    $uri = rawurldecode(httpget('u'));
    $text = stripslashes(rawurldecode(httpget('t')));
    $translation = translate_loadnamespace($uri);
    if (isset($translation[$text])) {
        $trans = $translation[$text];
    } else {
        $trans = "";
    }
    $namespace = translate_inline("Namespace:");
    $texta = translate_inline("Text:");
    $translation = translate_inline("Translation:");
    $saveclose = htmlentities(translate_inline("Save & Close"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
    $savenotclose = htmlentities(translate_inline("Save No Close"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
    rawoutput("<form action='translatortool.php?op=save' method='POST'>");
    rawoutput("{$namespace} <input name='uri' value=\"" . htmlentities(stripslashes($uri), ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" readonly><br/>");
    rawoutput("{$texta}<br>");
    rawoutput("<textarea name='text' cols='60' rows='5' readonly>" . htmlentities($text, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "</textarea><br/>");
    rawoutput("{$translation}<br>");
    rawoutput("<textarea name='trans' cols='60' rows='5'>" . htmlentities(stripslashes($trans), ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "</textarea><br/>");