本文整理汇总了PHP中Locales::getPluginLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Locales::getPluginLocale方法的具体用法?PHP Locales::getPluginLocale怎么用?PHP Locales::getPluginLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locales
的用法示例。
在下文中一共展示了Locales::getPluginLocale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Locale
/**
* @static
* Static method that offers some kind of locale factory. Since the Locale object
* better not use a Singleton (otherwise we couldn't use more than one locale file
* at a time) this function has been included here to provide a system similar to
* a singleton: we keep an static array inside the function, that contains all the
* locale files that have been loaded so far. Whenever somebody requests a locale
* to be fetched from disk, we will first check that we have not loaded it before. If
* we have, then we only have to return the same object we were keeping.
* If the locale wasn't there, we will then load it from disk and store/cache the
* resulting object for future use.
* It is recommended to use this method over creating new Locale objects every time
* we need one.
*
* @param localeCode The code (eg. en_UK, es_ES) of the locale we want to get.
* @return Returns a Locale object corresponding to the requested locale.
* @see Locale
*/
function &getLocale($localeCode = null)
{
// array to keep track of the locales that we have already loaded, so that
// we don't have to fetch them from disk
static $loadedLocales;
// if there is no locale parameter, we use the default one
if ($localeCode == null) {
$config =& Config::getConfig();
$localeCode = $config->getValue("default_locale");
}
// check if we have already loaded that locale or else, load it from
// disk and keep it for later, just in case anybody asks again
if (isset($loadedLocales[$localeCode])) {
$locale = $loadedLocales[$localeCode];
} else {
$locale = new Locale($localeCode);
$pm =& PluginManager::getPluginManager();
foreach ($pm->_pluginList as $pluginId) {
if ($pm->pluginHasLocale($pluginId, $localeCode)) {
// if the plugin provides the locale that we need, continue
$pluginLocale = Locales::getPluginLocale($pluginId, $localeCode);
} else {
// if not, try to load en_UK by default
if ($pm->pluginHasLocale($pluginId, "en_UK")) {
$pluginLocale = Locales::getPluginLocale($pluginId, "en_UK");
}
// if not en_UK locale available, forget about it...
}
// merge the plugin locale with the big locale
if (isset($pluginLocale)) {
$locale->mergeLocale($pluginLocale);
}
}
$loadedLocales[$localeCode] = $locale;
}
return $locale;
}
示例2: _loadPluginLocale
/**
* @private
*/
function _loadPluginLocale($pluginId, $locale)
{
return Locales::getPluginLocale($pluginId, $locale);
}