/**
  * método getInstance()
  * retorna a única instância de TTranslation
  */
 public static function getInstance()
 {
     // se não existe instância ainda
     if (empty(self::$instance)) {
         // instancia um objeto
         self::$instance = new TTranslation();
     }
     // retorna a instância
     return self::$instance;
 }
Exemplo n.º 2
0
 /** Gets TTranslationEntry object by property $property_name with value $property_value.
  * @return TTranslationEntry or NULL in case of error
  */
 public static function getTranslationEntry($property_name, $property_value, $translation_obj = NULL)
 {
     global $LINK_DB;
     $query = "SELECT * FROM translation_entry WHERE `{$property_name}`='{$property_value}' order by id";
     $result = $LINK_DB->query_e($query, "Query failed in " . __METHOD__ . " in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     if ($LINK_DB->query_count($result) == 0) {
         return NULL;
     }
     $translationEntry_arr = array();
     while ($row = $result->fetch_object()) {
         if ($translation_obj == NULL) {
             $translation_obj = TTranslation::getByID($row->translation_id);
         }
         $translationEntry_arr[] = new TTranslationEntry($row->id, $translation_obj, TLang::getByID($row->lang_id), TWikiText::getByID($row->wiki_text_id));
     }
     return $translationEntry_arr;
 }
Exemplo n.º 3
0
 /** Gets TTranslation object by meaning_id
  * @return TTranslation or NULL in case of error
  */
 public static function getByMeaning($meaning_id, $meaning_obj = NULL)
 {
     $translation_arr = TTranslation::getTranslation("meaning_id", $meaning_id, $meaning_obj);
     return $translation_arr[0];
 }
Exemplo n.º 4
0
 /** Gets TMeaning object by property $property_name with value $property_value.
  * @return TMeaning or NULL in case of error
  */
 public static function getMeaning($property_name, $property_value, $lang_pos_obj = NULL)
 {
     global $LINK_DB;
     $query = "SELECT * FROM meaning WHERE `{$property_name}`='{$property_value}' order by id";
     $result = $LINK_DB->query_e($query, "Query failed in " . __METHOD__ . " in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     if ($LINK_DB->query_count($result) == 0) {
         return NULL;
     }
     $meaning_arr = array();
     while ($row = $result->fetch_object()) {
         /*
                 if ($lang_pos_obj == NULL)
                 $lang_pos_obj = TLangPOS::getByID($row->lang_pos_id);
         */
         $meaning = new TMeaning($row->id, $lang_pos_obj, $row->lang_pos_id, $row->meaning_n, TWikiText::getByID($row->wiki_text_id), $row->wiki_text_id);
         $meaning->relation = TRelation::getByMeaning($row->id, $meaning);
         $meaning->translation = TTranslation::getByMeaning($row->id, $meaning);
         $meaning->label_meaning = TLabelMeaning::getByMeaning($row->id, $meaning);
         $meaning_arr[] = $meaning;
     }
     return $meaning_arr;
 }
Exemplo n.º 5
0
<?php

// inclui a classe TTranslation
include_once 'app.widgets/TTranslation.class.php';
// define a linguagem como português
TTranslation::setLanguage('pt');
echo "Em Português:<br>\n";
// imprime palavras traduzidas
echo _t('Function') . "<br>\n";
echo _t('Table') . "<br>\n";
echo _t('Tool') . "<br>\n";
// define a linguagem como italiano
TTranslation::setLanguage('it');
echo "Em Italiano:<br>\n";
// imprime palavras traduzidas
echo _t('Function') . "<br>\n";
echo _t('Table') . "<br>\n";
echo _t('Tool') . "<br>\n";
?>