/[cvs]/nfo/php/libs/org.netfrag.flib/Application/l10n/LocaleText.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.flib/Application/l10n/LocaleText.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by joko, Tue Dec 3 03:10:21 2002 UTC revision 1.4 by joko, Thu Dec 19 06:18:40 2002 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    ------------------------------------------------------------------  //    ------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.4  2002/12/19 06:18:40  joko
7    //    + '$this->site' gets used here now
8    //
9    //    Revision 1.3  2002/12/04 07:40:05  jonen
10    //    + comment out dprint
11    //
12  //    Revision 1.2  2002/12/03 03:10:21  joko  //    Revision 1.2  2002/12/03 03:10:21  joko
13  //    + bugfix regarding new object hierarchy  //    + bugfix regarding new object hierarchy
14  //  //
# Line 49  class LocaleText { Line 55  class LocaleText {
55        
56    // ----------------------------------------------------    // ----------------------------------------------------
57    function LocaleText() {    function LocaleText() {
58    
59        /*
60        // was:
61        global $cfg, $slt;
62        session_register_safe('slt');
63        $this->langs_avail = $cfg[GLBL_LANGSAVAIL];
64        $this->load();
65        */
66        
67        // look at the bottom of this file!!!
68        //$smarty->register_block("translate", "do_translation");
69        //$this->site->smarty->register_block("translate", "_do_translation");
70    
71        //global $site;
72        //$site->smarty->register_block("translate", "_do_translation");
73    
74      }
75    
76      function start() {
77      global $cfg, $slt;      global $cfg, $slt;
78      session_register_safe('slt');      session_register_safe('slt');
79      $this->langs_avail = $cfg[GLBL_LANGSAVAIL];      $this->langs_avail = $cfg[GLBL_LANGSAVAIL];
# Line 100  class LocaleText { Line 125  class LocaleText {
125    }    }
126        
127    function _getldsvar($ldskey, $tpl=array()) {    function _getldsvar($ldskey, $tpl=array()) {
128        
129    //print "ldskey: $ldskey<br>";
130    
131      $var_name = '$this->lds' . $ldskey;      $var_name = '$this->lds' . $ldskey;
132      $eval_string = "return $var_name;";      $eval_string = "return $var_name;";
133      //print $eval_string . "<br>";      //print $eval_string . "<br>";
134    
135      // interpolate variable-name      // interpolate variable-name
136      $var_value = eval($eval_string);      $var_value = eval($eval_string);
137      // interpolate variable-value to do some template-vars      // interpolate variable-value to do some template-vars
138      $var_value = eval("return \"$var_value\";");      //$var_value = eval("return \"$var_value\";");
139    
140        // V1 - result interpolation using eval
141      // print $eval_string."<br>";      // print $eval_string."<br>";
142      //$var_value = $$var_name;      //$var_value = $$var_name;
143    
144        // V2 - result interpolation using smarty
145        //print Dumper($tpl);
146        //$this->site->loadTemplate();
147    
148      return $var_value;      return $var_value;
149    }    }
150        
# Line 122  class LocaleText { Line 158  class LocaleText {
158    }    }
159        
160    function _loadStructure_FromDb() {    function _loadStructure_FromDb() {
161      global $site;      //global $site;
162      $site->log( get_class($this) . "->_loadStructure_FromDb loading language information", LOG_DEBUG);      $this->site->log( get_class($this) . "->_loadStructure_FromDb loading language information", LOG_DEBUG);
163      //print "- loading structure from db ($this->langkey)<br>";      //print "- loading structure from db ($this->langkey)<br>";
164      //connectdb();      //connectdb();
165      $sql = "SELECT * FROM td_res_langtext WHERE countrykey='" . $this->langkey . "'";      $sql = "SELECT * FROM td_res_langtext WHERE countrykey='" . $this->langkey . "'";
166      if ($result = $site->db->query($sql)) {      if ($result = $this->site->db->query($sql)) {
167        //while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {        //while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
168        while ( $result->fetchInto($row) ) {        while ( $result->fetchInto($row) ) {
169           //print $row[tval]."<br>";           //print $row[tval]."<br>";
# Line 135  class LocaleText { Line 171  class LocaleText {
171            $this->_loadStructure_FromDb_add($row["tkey"], $row["tval"]);            $this->_loadStructure_FromDb_add($row["tkey"], $row["tval"]);
172        }        }
173      }      }
174      $site->log( get_class($this) . "->_loadStructure_FromDb ready", LOG_DEBUG);      $this->site->log( get_class($this) . "->_loadStructure_FromDb ready", LOG_DEBUG);
175    }    }
176        
177    function _loadStructure_FromDb_add($dbkey, $val) {    function _loadStructure_FromDb_add($dbkey, $val) {
# Line 184  class LocaleText { Line 220  class LocaleText {
220    }    }
221        
222    function getlt($key, $tpl=array()) {    function getlt($key, $tpl=array()) {
223      dprint("getlt: $key");      //dprint("getlt: $key");
224      if ($ldskey = $this->_dbkey2ldskey($key)) {      if ($ldskey = $this->_dbkey2ldskey($key)) {
225        return $this->_getldsvar($ldskey, $tpl);        return $this->_getldsvar($ldskey, $tpl);
226      }      }
# Line 192  class LocaleText { Line 228  class LocaleText {
228    
229  }  }
230    
231    
232    
233    /*
234    Example 13-17. register_block
235    taken from: http://smarty.php.net/manual/en/api.register.block.html
236    will be triggered by this template-code:
237      {* template *}
238      {translate lang="br"}
239         Hello, world!
240      {/translate}
241    */
242    
243      /* PHP */
244      //global $smarty;
245      //$smarty->register_block("translate", "do_translation");
246    
247    /*  
248      function _do_translation ($params, $content, &$smarty) {
249          print "do_translation<br>";
250          print "params: " . Dumper($params) . "<br>";
251          print "content: $content<br>";
252          if ($content) {
253              //$lang = $params['lang'];
254              // do some translation with $content
255              //echo $translation;
256              return getlt($content);
257          }
258      }
259    */
260      
261  ?>  ?>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed