Beispiel #1
0
 public static function load_language($lang = null)
 {
     if ($lang && file_exists(self::$options['ENGINE_ROOT'] . 'lang/' . $lang . '.php')) {
         self::$translations = (include self::$options['ENGINE_ROOT'] . 'lang/' . $lang . '.php');
     } elseif (file_exists(self::$options['ENGINE_ROOT'] . 'lang/' . self::default_lang . '.php')) {
         self::$translations = (include self::$options['ENGINE_ROOT'] . 'lang/' . self::default_lang . '.php');
     }
 }
Beispiel #2
0
 /**
  *
  * Translates $string into language I18n::$locale and caches all found translations on the first call
  *
  * @return                 The translated String
  * @param string $string   The String to translate
  */
 public static function get_text($string)
 {
     if (!I18n::$translations) {
         $locale = explode('_', I18n::get_locale(FALSE));
         // Get the translation files
         $translation_files = Kohana::find_file('i18n', $locale[0]);
         if ($local_translation_files = Kohana::find_file('i18n', $locale[0] . '/' . $locale[1])) {
             $translation_files = array_merge($translation_files, $local_translation_files);
         }
         if ($translation_files) {
             // Merge the translations
             foreach ($translation_files as $file) {
                 include $file;
                 I18n::$translations = array_merge(I18n::$translations, $translations);
             }
         }
     }
     if (isset(I18n::$translations[$string])) {
         return I18n::$translations[$string];
     } else {
         return $string;
     }
 }