當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CLocale::getLocaleIDs方法代碼示例

本文整理匯總了PHP中CLocale::getLocaleIDs方法的典型用法代碼示例。如果您正苦於以下問題:PHP CLocale::getLocaleIDs方法的具體用法?PHP CLocale::getLocaleIDs怎麽用?PHP CLocale::getLocaleIDs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CLocale的用法示例。


在下文中一共展示了CLocale::getLocaleIDs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     echo PHP_EOL;
     if (!isset($args[0])) {
         $this->usageError('A language pack archive file must be specified.');
     }
     // Start
     $msg_file = INSTANCE_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands' . DIRECTORY_SEPARATOR . $args[0];
     if (!file_exists($msg_file)) {
         $this->usageError('The provided filename does not exist.');
     }
     $zip = new ZipArchive();
     if ($zip->open($msg_file) === true) {
         if ($zip->numFiles > 0) {
             $overwriteAll = false;
             $locales = CLocale::getLocaleIDs();
             for ($i = 0; $i < $zip->numFiles; $i++) {
                 $zip->renameIndex($i, substr($zip->getNameIndex($i), strpos($zip->getNameIndex($i), 'app/')));
                 $entry = $zip->getNameIndex($i);
                 if (preg_match('#(__MACOSX)#i', $entry)) {
                     continue;
                 }
                 if (preg_match('#\\.(php)$#i', $entry)) {
                     $extractPath = substr(INSTANCE_ROOT, 0, -strlen('app/')) . DIRECTORY_SEPARATOR;
                     $file = $extractPath . $entry;
                     if (is_file($file)) {
                         preg_match('#(.*)\\/messages\\/(.*)\\/(.*)#i', $entry, $matches);
                         if (is_array($matches)) {
                             $lang = $matches[2];
                         }
                         if (!in_array($lang, $locales)) {
                             echo ' Message-file `' . $entry . '` ignored. Language `' . $lang . '` is not a supported language/locale.' . PHP_EOL;
                             continue;
                         }
                         if ($overwriteAll) {
                             echo ' Message-file `' . $entry . '` overwritten.' . PHP_EOL;
                         } else {
                             echo '  Message-file `' . $entry . '` already exists but different.' . PHP_EOL;
                             $answer = $this->prompt('    ...Overwrite? [Yes|No|All|Quit] ');
                             if (!strncasecmp($answer, 'q', 1)) {
                                 return;
                             } elseif (!strncasecmp($answer, 'y', 1)) {
                                 echo ' Message-file `' . $entry . '` overwritten.' . PHP_EOL;
                             } elseif (!strncasecmp($answer, 'a', 1)) {
                                 echo ' Message-file `' . $entry . '` overwritten.' . PHP_EOL;
                                 $overwriteAll = true;
                             } else {
                                 echo ' Message-file `' . $entry . '` skipped.' . PHP_EOL;
                                 continue;
                             }
                         }
                     }
                     $res = $zip->extractTo($extractPath, array($entry));
                     if ($res) {
                         echo ' Message-file `' . $entry . '` successfully extracted.' . PHP_EOL;
                     }
                 }
             }
         } else {
             $this->usageError('The ZIP archive contains no files.');
         }
         $zip->close();
         if (!is_writable($msg_file)) {
             echo 'Unable to remove ZIP Archive file. Please verify the file permissions.';
         } else {
             unlink($msg_file);
         }
     } else {
         $this->usageError('Error opening the ZIP archive.');
     }
 }
開發者ID:maruthisivaprasad,項目名稱:zurmo,代碼行數:75,代碼來源:InstallLanguageCommand.php


注:本文中的CLocale::getLocaleIDs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。