function translate($txt) { if (is_array($txt)) { $args = $txt; } else { $args = func_get_args(); } $txt = array_shift($args); // Test if constant exists (constant without space) if (!defined($txt) && find($txt, " ") == 0) { if (!($key = getConstantName($txt))) { // auto create constant in translation files create_label_translation($txt); } } // Encode data $array_lang_convert_html = array('ru'); if ($GLOBALS['__AJAX_LOAD_PAGE__'] == true && !in_array($_GET['l'], $array_lang_convert_html) && (find($_GET['mime'], "xml") > 0 || find($_GET['mime'], "rss") > 0)) { $txt = utf8decode($txt); } else { $txt = utf8encode($txt); } // convert %s by args for ($i = 0; $i < sizeof($args); $i++) { if ($GLOBALS['__AJAX_LOAD_PAGE__'] == true && !in_array($_GET['l'], $array_lang_convert_html) && (find($_GET['mime'], "xml") > 0 || find($_GET['mime'], "rss") > 0)) { $txt = preg_replace('/%s/', utf8decode($args[$i]), $txt, 1); } else { $txt = preg_replace('/%s/', utf8encode($args[$i]), $txt, 1); } } if ($GLOBALS['__AJAX_LOAD_PAGE__'] == true && in_array($_GET['l'], $array_lang_convert_html) && (find($_GET['mime'], "xml") > 0 || find($_GET['mime'], "rss") > 0)) { $txt = convert_utf8_to_html($txt); } return $txt; }
function createConst($filename) { define(getConstantName($filename), $filename); }