Exemplo n.º 1
0
 /**
  * Returns translation of a string. If no translation exists, the original
  * string will be returned. No parameters are replaced.
  *
  *     $hello = I18n::get('Hello friends, my name is :name');
  *
  * @param   string  $string text to translate
  * @param   string  $lang   target language
  * @return  string
  */
 public static function get($string, $lang = NULL)
 {
     if (!$lang) {
         // Use the global target language
         $lang = Lang::instance()->getCurrentLang()['iso'];
     }
     // Load the translation table for this language
     $items = I18n::load($lang);
     // Return the translated string if it exists
     return isset($items[$string]) ? $items[$string] : $string;
 }