本文整理汇总了PHP中AppLocale::getFilenameComponentMap方法的典型用法代码示例。如果您正苦于以下问题:PHP AppLocale::getFilenameComponentMap方法的具体用法?PHP AppLocale::getFilenameComponentMap怎么用?PHP AppLocale::getFilenameComponentMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppLocale
的用法示例。
在下文中一共展示了AppLocale::getFilenameComponentMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocaleFiles
/**
* Get a list of locale files for the given locale code.
* @param $locale string Locale code
* @return array List of filenames
*/
function getLocaleFiles($locale)
{
if (!AppLocale::isLocaleValid($locale)) {
return null;
}
$localeFiles = AppLocale::getFilenameComponentMap($locale);
$plugins =& PluginRegistry::loadAllPlugins();
foreach (array_keys($plugins) as $key) {
$plugin =& $plugins[$key];
$localeFile = $plugin->getLocaleFilename($locale);
if (!empty($localeFile)) {
if (is_scalar($localeFile)) {
$localeFiles[] = $localeFile;
}
if (is_array($localeFile)) {
$localeFiles = array_merge($localeFiles, $localeFile);
}
}
unset($plugin);
}
return $localeFiles;
}
示例2: requireComponents
function requireComponents($components, $locale = null)
{
$loadedComponents =& Registry::get('loadedLocaleComponents', true, array());
if ($locale === null) {
$locale = AppLocale::getLocale();
}
$filenameComponentMap = AppLocale::getFilenameComponentMap($locale);
foreach ($components as $component) {
// Don't load components twice
if (isset($loadedComponents[$locale][$component])) {
continue;
}
if (!isset($filenameComponentMap[$component])) {
fatalError('Unknown locale component ' . $component);
}
$filename = $filenameComponentMap[$component];
AppLocale::registerLocaleFile($locale, $filename);
$loadedComponents[$locale][$component] = true;
}
}
示例3: testLocale
/**
* Test all locale files for the supplied locale against the supplied
* reference locale, returning an array of errors.
* @param $locale string Name of locale to test
* @param $referenceLocale string Name of locale to test against
* @return array
*/
function testLocale($locale, $referenceLocale)
{
$localeFileNames = AppLocale::getFilenameComponentMap($locale);
$errors = array();
foreach ($localeFileNames as $localeFileName) {
$referenceLocaleFileName = str_replace($locale, $referenceLocale, $localeFileName);
$localeFile = new LocaleFile($locale, $localeFileName);
$referenceLocaleFile = new LocaleFile($referenceLocale, $referenceLocaleFileName);
$errors = array_merge_recursive($errors, $localeFile->testLocale($referenceLocaleFile));
unset($localeFile);
unset($referenceLocaleFile);
}
$plugins =& PluginRegistry::loadAllPlugins();
foreach (array_keys($plugins) as $key) {
$plugin =& $plugins[$key];
$referenceLocaleFilenames = $plugin->getLocaleFilename($referenceLocale);
if ($referenceLocaleFilenames) {
if (is_scalar($referenceLocaleFilenames)) {
$referenceLocaleFilenames = array($referenceLocaleFilenames);
}
$localeFilenames = $plugin->getLocaleFilename($locale);
if (is_scalar($localeFilenames)) {
$localeFilenames = array($localeFilenames);
}
assert(count($localeFilenames) == count($referenceLocaleFilenames));
foreach ($referenceLocaleFilenames as $index => $referenceLocaleFilename) {
assert(isset($localeFilenames[$index]));
$localeFile = new LocaleFile($locale, $localeFilenames[$index]);
$referenceLocaleFile = new LocaleFile($referenceLocale, $referenceLocaleFilename);
$errors = array_merge_recursive($errors, $localeFile->testLocale($referenceLocaleFile));
unset($localeFile);
unset($referenceLocaleFile);
}
}
unset($plugin);
}
return $errors;
}
示例4: requireComponents
/**
* Load a set of locale components. Parameters of mixed length may
* be supplied, each a LOCALE_COMPONENT_... constant. An optional final
* parameter may be supplied to specify the locale (e.g. 'en_US').
*/
static function requireComponents()
{
$params = func_get_args();
$paramCount = count($params);
if ($paramCount === 0) {
return;
}
// Get the locale
$lastParam = $params[$paramCount - 1];
if (is_string($lastParam)) {
$locale = $lastParam;
$paramCount--;
} else {
$locale = AppLocale::getLocale();
}
// Backwards compatibility: the list used to be supplied
// as an array in the first parameter.
if (is_array($params[0])) {
$params = $params[0];
$paramCount = count($params);
}
// Go through and make sure each component is loaded if valid.
$loadedComponents =& Registry::get('loadedLocaleComponents', true, array());
$filenameComponentMap = AppLocale::getFilenameComponentMap($locale);
for ($i = 0; $i < $paramCount; $i++) {
$component = $params[$i];
// Don't load components twice
if (isset($loadedComponents[$locale][$component])) {
continue;
}
// Validate component
if (!isset($filenameComponentMap[$component])) {
fatalError('Unknown locale component ' . $component);
}
$filename = $filenameComponentMap[$component];
AppLocale::registerLocaleFile($locale, $filename);
$loadedComponents[$locale][$component] = true;
}
}