pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by meeech on Fri 20 Jun 15:29
report abuse | download | new post

  1. <?php
  2.  
  3. /**
  4.  * Class to handle translation for EE. Mainly intended for small chunks.
  5.  *
  6.  * Idea is it can be called from a template as
  7.  * {exp:xlate t="to_translate"}
  8.  **/
  9. class Xlate {
  10.        
  11.         var $return_data = "";
  12.  
  13.         var $current_language;
  14.         var $current_lang_code;
  15.         var $to_xlate;
  16.        
  17.         function Xlate()
  18.         {
  19.                
  20.                 global $TMPL, $IN, $LANG, $SESS;
  21.                
  22.                 $this->current_language = $IN->global_vars['language'];
  23.                 $this->current_lang_code = $IN->global_vars['language_code'];
  24.                
  25.                 //Assign the user language
  26.                 $SESS->userdata['language'] = $this->current_language;
  27.                
  28.                 $this->to_xlate = $TMPL->fetch_param('t');
  29.  
  30.                 $LANG->fetch_language_file('gg_mentor');
  31.  
  32.                 //And translate!
  33.                 $this->return_data = $this->in();
  34.  
  35.         }
  36.        
  37.         /**
  38.          * Takes in text to xlate
  39.          *
  40.          * Usages example: would like tags like {exp:xlate:in t="Text to translate here.        "}
  41.          * @return string
  42.          **/
  43.         function in($to_translate = false)
  44.         {
  45.                 global $LANG;
  46.                
  47.                 if($to_translate){
  48.                         $this->to_xlate = $to_translate;
  49.                 }
  50.                
  51.                 $translated = $LANG->line($this->to_xlate);
  52.                 if('' == $translated) {
  53.                         $translated = $this->to_xlate;
  54.                 }
  55.  
  56.                 return $translated;
  57.  
  58.         }
  59.        
  60. } // END class Xlate

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post