コード例 #1
0
 /**
  * Initialize all activated plugin by including is index.php file.
  * Also load all language files for plugins available in plugins directory.
  */
 static function init()
 {
     $dir = PLUGINS_ROOT . DS;
     if ($handle = opendir($dir)) {
         while (false !== ($plugin_id = readdir($handle))) {
             $file = $dir . $plugin_id . DS . 'i18n' . DS . I18n::getLocale() . '-message.php';
             $default_file = PLUGINS_ROOT . DS . $plugin_id . DS . 'i18n' . DS . DEFAULT_LOCALE . '-message.php';
             if (file_exists($file)) {
                 $array = (include $file);
                 I18n::add($array);
             }
             if (file_exists($default_file)) {
                 $array = (include $default_file);
                 I18n::addDefault($array);
             }
         }
     }
     self::$plugins = unserialize(Setting::get('plugins'));
     foreach (self::$plugins as $plugin_id => $tmp) {
         $file = PLUGINS_ROOT . DS . $plugin_id . DS . 'index.php';
         if (file_exists($file)) {
             include $file;
         }
     }
 }
コード例 #2
0
ファイル: I18n.php プロジェクト: julpi/FreshCMS
/**
 * This function is as flexible as possible, you can choose your own pattern for variables in
 * the string.
 *
 * Examples of variables are: ':var_name', '#var_name', '{varname}',
 * '%varname', '%varname%', 'VARNAME', etc...
 *
 * <code>
 * return = array('hello world!' => 'bonjour le monde!',
 *                'user ":user" is logged in' => 'l\'utilisateur ":user" est connecté',
 *                'Posted by %user% on %month% %day% %year% at %time%' => 'Publié par %user% le %day% %month% %year% à %time%'
 *               );
 *
 * __('hello world!'); // bonjour le monde!
 * __('user ":user" is logged in', array(':user' => $user)); // l'utilisateur "demo" est connecté
 * __('Posted by %user% on %month% %day% %year% at %time%', array(
 *      '%user%' => $user,
 *      '%month%' => __($month),
 *      '%day%' => $day,
 *      '%year%' => $year,
 *      '%time%' => $time)); // Publié par demo le 3 janvier 2006 à 19:30
 * </code>
 */
function __($string, $args = null)
{
    if (I18n::getLocale() != DEFAULT_LOCALE) {
        $string = I18n::getText($string);
    }
    if ($args === null) {
        return $string;
    }
    return strtr($string, $args);
}
コード例 #3
0
ファイル: format.class.php プロジェクト: salomalo/php-oxygen
 /**
  * Returns dateFormat instance
  * 
  * @return f_date_Format    Return singleton instance of f_date_Format
  */
 public static function getInstance($region = null)
 {
     if ($region === null) {
         $region = I18n::getLocale();
     }
     if (!isset(self::$_instances[$region])) {
         self::$_instances[$region] = new self($region);
     }
     return self::$_instances[$region];
 }
コード例 #4
0
ファイル: Plugin.php プロジェクト: julpi/FreshCMS
 /**
  * Initialize all activated plugin by including is index.php file
  */
 static function init()
 {
     self::$plugins = unserialize(Setting::get('plugins'));
     foreach (self::$plugins as $plugin_id => $tmp) {
         $file = CORE_ROOT . '/plugins/' . $plugin_id . '/index.php';
         if (file_exists($file)) {
             include $file;
         }
         $file = CORE_ROOT . '/plugins/' . $plugin_id . '/i18n/' . I18n::getLocale() . '-message.php';
         if (file_exists($file)) {
             $array = (include $file);
             I18n::add($array);
         }
     }
 }
コード例 #5
0
 private function _filemanager_lang()
 {
     $trans = array('ca', 'cs', 'da', 'de', 'en', 'es', 'fi', 'fr', 'he', 'hu', 'it', 'ja', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'vn', 'cn');
     $user_lang = I18n::getLocale();
     $lang = in_array($user_lang, $trans) ? $user_lang : 'en';
     if ($lang == 'cn') {
         $lang = 'zh-cn';
     }
     return $lang;
 }
コード例 #6
0
ファイル: upload.class.php プロジェクト: salomalo/php-oxygen
 /**
  * Return code and message from a given error code
  * 
  * @param integer $code
  * @return array            Array containing the error code and the error text
  */
 private function _addErrorMessage($code)
 {
     $codes = array(UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload', self::UPLOAD_ERR_MAX_SIZE => 'The file uploaded exceeds the maximum file size defined in the configuration', self::UPLOAD_ERR_FILE_EXTENSION => 'The extension of the file uploaded is blacklisted or not whitelisted', self::UPLOAD_ERR_FILE_TYPE => 'The type of the file uploaded is blacklisted or not whitelisted', self::UPLOAD_ERR_FILE_NOT_IMAGE => 'The file uploaded is not an image', self::UPLOAD_ERR_MOVE_FAILED => 'The uploaded filename could not be moved from temporary storage to the path specified', self::UPLOAD_ERR_OVERWRITE => 'The uploaded filename could not be saved because a file with that name already exists');
     $this->errors[$code] = I18n::t(FW_DIR . DS . 'lib' . DS . 'locales' . DS . 'upload.' . I18n::getLocale() . '.xml', $codes[$code], array(), 'en_US');
 }