Esempio n. 1
0
 /**
  * checks the i18n folder to see what folders we have available
  */
 public static function get_i18n()
 {
     $locales = array();
     // i18n path
     $i18n_path = APPPATH . 'i18n/';
     // i18n folder
     $i18n_folder = @opendir($i18n_path);
     if (!$i18n_folder) {
         return false;
     }
     while (($i18n_dir = readdir($i18n_folder)) !== false) {
         if (is_dir($i18n_path . $i18n_dir) && is_readable($i18n_path . $i18n_dir)) {
             // Strip out .  and .. and any other stuff
             if ($i18n_dir[0] == '.' || $i18n_dir == '..' || $i18n_dir == '.DS_Store' || $i18n_dir == '.git') {
                 continue;
             }
             $locale = explode("_", $i18n_dir);
             if (count($locale) < 2) {
                 continue;
             }
             $directories[$i18n_dir] = ush_locale::language($locale[0]) . " (" . $locale[1] . ")";
         }
     }
     if (is_dir($i18n_dir)) {
         @closedir($i18n_dir);
     }
     return $directories;
 }
Esempio n. 2
0
 /**
  * checks the i18n folder to see what folders we have available
  * @param boolean Force reloading locale cache
  */
 public static function get_i18n($refresh = FALSE)
 {
     // If we had cached locales return those
     if (!$refresh) {
         $locales = Cache::instance()->get('locales');
         if ($locales) {
             return $locales;
         }
     }
     $locales = array();
     // i18n path
     $i18n_path = APPPATH . 'i18n/';
     // i18n folder
     $i18n_folder = @opendir($i18n_path);
     if (!$i18n_folder) {
         return false;
     }
     while (($i18n_dir = readdir($i18n_folder)) !== false) {
         if (is_dir($i18n_path . $i18n_dir) && is_readable($i18n_path . $i18n_dir)) {
             // Strip out .  and .. and any other stuff
             if ($i18n_dir[0] == '.' || $i18n_dir == '..' || $i18n_dir == '.DS_Store' || $i18n_dir == '.git') {
                 continue;
             }
             $locale = explode("_", $i18n_dir);
             if (count($locale) < 2 and !ush_locale::language($locale[0])) {
                 continue;
             }
             $locales[$i18n_dir] = ush_locale::language($locale[0]) ? ush_locale::language($locale[0]) : $locale[0];
             $locales[$i18n_dir] .= isset($locale[1]) ? " (" . $locale[1] . ")" : "";
         }
     }
     if (is_dir($i18n_dir)) {
         @closedir($i18n_dir);
     }
     Cache::instance()->set('locales', $locales, array('locales'), 604800);
     return $locales;
 }