本文整理汇总了PHP中Locale::getLocaleFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getLocaleFiles方法的具体用法?PHP Locale::getLocaleFiles怎么用?PHP Locale::getLocaleFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::getLocaleFiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Create the test locale file.
*/
function execute()
{
Locale::initialize();
$localeFiles =& Locale::getLocaleFiles();
$localeFile = array_shift($localeFiles[$this->inLocale]);
$localeData = LocaleFile::load($localeFile->filename);
if (!isset($localeData)) {
printf('Invalid locale \'%s\'', $this->inLocale);
exit(1);
}
$outFile = sprintf('locale/%s/locale.xml', $this->outLocale);
$fp = fopen($outFile, 'wb');
if (!$fp) {
printf('Failed to write to \'%s\'', $outFile);
exit(1);
}
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE locale SYSTEM \"../locale.dtd\">\n\n" . "<!--\n" . " * locale.xml\n" . " *\n" . " * Copyright (c) 2003-2007 John Willinsky\n" . " * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.\n" . " *\n" . sprintf(" * Localization strings for the %s (%s) locale.\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME) . " *\n" . " * \$Id\$\n" . " -->\n\n" . sprintf("<locale name=\"%s\" full_name=\"%s\">\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME));
foreach ($localeData as $key => $message) {
$outMessage = $this->fancifyString($message);
if (strstr($outMessage, '<') || strstr($outMessage, '>')) {
$outMessage = '<![CDATA[' . $outMessage . ']]>';
}
fwrite($fp, sprintf("\t<message key=\"%s\">%s</message>\n", $key, $outMessage));
}
fwrite($fp, "</locale>\n");
fclose($fp);
}
示例2: register
function register($category, $path)
{
if (parent::register($category, $path)) {
$this->addLocaleData();
if ($this->getEnabled()) {
// Add custom locale data for already registered locale files.
$locale = Locale::getLocale();
$localeFiles = Locale::getLocaleFiles($locale);
$journal = Request::getJournal();
$journalId = $journal->getId();
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$customLocalePathBase = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR;
import('file.FileManager');
foreach ($localeFiles as $localeFile) {
$customLocalePath = $customLocalePathBase . $localeFile->getFilename();
if (FileManager::fileExists($customLocalePath)) {
Locale::registerLocaleFile($locale, $customLocalePath, true);
}
}
// Add custom locale data for all locale files registered after this plugin
HookRegistry::register('PKPLocale::registerLocaleFile', array(&$this, 'addCustomLocale'));
}
return true;
}
return false;
}
示例3: register
function register($category, $path)
{
if (parent::register($category, $path)) {
if ($this->getEnabled()) {
import('lib.pkp.classes.file.FileManager');
$press = Request::getPress();
$pressId = $press->getId();
$locale = Locale::getLocale();
$localeFiles = Locale::getLocaleFiles($locale);
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$customLocaleDir = $publicFilesDir . DIRECTORY_SEPARATOR . 'presses' . DIRECTORY_SEPARATOR . $pressId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR;
foreach ($localeFiles as $localeFile) {
$localeFilename = $localeFile->getFilename();
$customLocalePath = $customLocaleDir . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename;
if (FileManager::fileExists($customLocalePath)) {
Locale::registerLocaleFile($locale, $customLocalePath, true);
}
}
}
return true;
}
return false;
}
示例4: LocaleFile
/**
* Register a locale file against the current list.
* @param $locale string Locale key
* @param $filename string Filename to new locale XML file
* @param $addToTop boolean Whether to add to the top of the list (true)
* or the bottom (false). Allows overriding.
*/
function ®isterLocaleFile($locale, $filename, $addToTop = false)
{
$localeFiles =& Locale::getLocaleFiles($locale);
$localeFile =& new LocaleFile($locale, $filename);
if (!$localeFile->isValid()) {
$localeFile = null;
return $localeFile;
}
if ($addToTop) {
// Work-around: unshift by reference.
array_unshift($localeFiles, '');
$localeFiles[0] =& $localeFile;
} else {
$localeFiles[] =& $localeFile;
}
return $localeFile;
}