本文整理汇总了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.');
}
}