Posted by meeech on Fri 20 Jun 15:29
report abuse | download | new post
- <?php
- /**
- * Class to handle translation for EE. Mainly intended for small chunks.
- *
- * Idea is it can be called from a template as
- * {exp:xlate t="to_translate"}
- **/
- class Xlate {
- var $return_data = "";
- var $current_language;
- var $current_lang_code;
- var $to_xlate;
- function Xlate()
- {
- $this->current_language = $IN->global_vars['language'];
- $this->current_lang_code = $IN->global_vars['language_code'];
- //Assign the user language
- $SESS->userdata['language'] = $this->current_language;
- $this->to_xlate = $TMPL->fetch_param('t');
- $LANG->fetch_language_file('gg_mentor');
- //And translate!
- $this->return_data = $this->in();
- }
- /**
- * Takes in text to xlate
- *
- * Usages example: would like tags like {exp:xlate:in t="Text to translate here. "}
- * @return string
- **/
- function in($to_translate = false)
- {
- global $LANG;
- if($to_translate){
- $this->to_xlate = $to_translate;
- }
- $translated = $LANG->line($this->to_xlate);
- if('' == $translated) {
- $translated = $this->to_xlate;
- }
- return $translated;
- }
- } // 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.