/** * retorna um vetor com a tradução * @param string $language - lingua referente da tradução * @param string $group - Nome do grupo/modulo que a tradução pertence * @return Translation_Entry */ function getTranslate($language, $group = 'default') { $sql = "SELECT s.*, t.*,\n\t\t\t\t\t(SELECT t.translation FROM {locales_target} t WHERE s.lid = t.plid) AS tplural,\n\t\t\t\t\t(SELECT s.source FROM {locales_source} s Where s.lid = \n\t\t\t\t\t(SELECT t.lid FROM {locales_target} t WHERE t.translation = tplural)) AS plural\n\t\t\t\tFROM {locales_source} s\n\t\t\t\tLEFT JOIN {locales_target} t ON s.lid = t.lid\n\t\t\t\tAND t.language = '{$language}'\n\t\t\t\tWHERE s.textgroup = '{$group}' AND t.plural = false"; $result = $this->SqlSelect($sql); if (mysql_affected_rows() > 0) { while ($linha = mysql_fetch_assoc($result)) { $args = poFormater($linha); $headers = hpoFormater($linha); $out[$linha['source']] = new Translation_Entry($args); } return (object) array('entries' => $out, "headers" => $headers, "_nplurals" => $language['language']->plurals, "_gettext_select_plural_form" => "�lambda_1103"); } }
public function LoadLanguage($group = 'default') { $mysql = new MYSQL($this); $langto = $this->cfg['language_default']; $sql = "SELECT s.lid, s.source, s.textgroup, s.location, t.translation, t.plid,\n\t\t\t\t\t(SELECT t.translation FROM {$this->cfg[db_prefix]}locales_target t WHERE s.lid = t.plid) AS tplural,\n\t\t\t\t\t(SELECT s.source FROM {$this->cfg[db_prefix]}locales_source s Where s.lid = \n\t\t\t\t\t(SELECT t.lid FROM {$this->cfg[db_prefix]}locales_target t WHERE t.translation = tplural)) AS plural\n\t\t\t\tFROM {$this->cfg[db_prefix]}locales_source s\n\t\t\t\tLEFT JOIN {$this->cfg[db_prefix]}locales_target t ON s.lid = t.lid\n\t\t\t\tAND t.language = '{$langto->language}'\n\t\t\t\tWHERE s.textgroup = '{$group}' AND t.plural = false"; $result = $mysql->SqlSelect($sql, __FILE__, __LINE__); if (mysql_affected_rows() > 0) { while ($linha = mysql_fetch_assoc($result)) { $args = poFormater($linha); $this->language['translation'][$linha['source']] = new Translation_Entry($args); } } else { if ($po_file = $this->LoadPo($langto->language, $group)) { //carrega uma linguagem para o banco de dados caso não exista nenhuma $args = po_db($po_file, $group); $result = $mysql->SqlSelect($mysql->SqlInsert($args), __FILE__, __LINE__); $this->language['translation'] = $po_file; } } }