function __($text, $lgfrom = "auto") { //return $text; if ($lgfrom === "auto") { $lgfrom = I18n::GetDefault(); } $calledFrom = debug_backtrace(); //return "<span id=\"".sha1($text)."\" lang=\"".$_LG->Get()."\">".$_LG->_($text,$lgfrom,$calledFrom[0]['file'],$calledFrom[0]['line'])."</span>"; $file = str_replace(ROOT . "/", '', $calledFrom[0]['file']); $var = I18n::_($text, $lgfrom, $file, $calledFrom[0]['line']); //debug(I18n::$_translations); if (preg_match_all('#\\[(\\w+)]#', $var, $m)) { //print_r( $m ); } if (count($m[1]) > 0) { $replace_with = array(); foreach ($m[1] as $species) { $scientific_name = str_replace("_", " ", $species); $sql = "SELECT b.text \r\n\t\t\t\tFROM species_main a\r\n\t\t\t\tinner JOIN scientific_name_translation b ON a.id = b.id_species_main AND b.id_species_sub = 0 and b.is_valid=1\r\n\t\t\t\tINNER JOIN language c ON c.iso3 = b.language AND c.iso = '" . I18n::Get() . "'\r\n\t\t\twhere a.scientific_name ='" . $scientific_name . "'"; $res = I18n::getDb()->sql(I18n::DATABASE)->sql_query($sql); if (I18n::getDb()->sql(I18n::DATABASE)->sql_num_rows($res) == 1) { $ob = I18n::getDb()->sql(I18n::DATABASE)->sql_fetch_object($res); $replace_with[] = $ob->text . " (" . $scientific_name . ")"; } else { $replace_with[] = $scientific_name; } } $var = str_replace($m[0], $replace_with, $var); } return $var; }