本文整理汇总了PHP中sfApplicationConfiguration::getI18NGlobalDirs方法的典型用法代码示例。如果您正苦于以下问题:PHP sfApplicationConfiguration::getI18NGlobalDirs方法的具体用法?PHP sfApplicationConfiguration::getI18NGlobalDirs怎么用?PHP sfApplicationConfiguration::getI18NGlobalDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfApplicationConfiguration
的用法示例。
在下文中一共展示了sfApplicationConfiguration::getI18NGlobalDirs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getI18NGlobalDirs
/**
* Gets the i18n directories to use globally.
*
* @return array An array of i18n directories
*/
public function getI18NGlobalDirs()
{
// if there is a configuration dimension
if ($this->hasDimension()) {
$cacheKey = 'sf_i18n_global_dirs';
// if there is a cache return it
if ($this->dimension->getCache()->has($cacheKey)) {
$dirs = $this->dimension->getCache()->get($cacheKey);
} else {
$dirs = array();
// application
if (is_dir($dir = sfConfig::get('sf_app_dir') . '/i18n')) {
array_push($dirs, $dir);
}
// plugins
$pluginDirs = glob(sfConfig::get('sf_plugins_dir') . '/*/i18n');
if (isset($pluginDirs[0])) {
array_push($dirs, $pluginDirs[0]);
}
// save cache
$this->dimension->getCache()->set($cacheKey, $dirs);
}
} else {
$dirs = parent::getI18NGlobalDirs();
}
return $dirs;
}
示例2: getInstalledCultures
/**
* This method is charged to get the cultures currently installed in the application.
* It parses the mgmt/i18n/ directory and determine which languages are available.
* @param sfApplicationConfiguration $configuration
* @return an array of symbols (such as 'en', 'fr', 'de',...) representing the languages currently installed.
*/
public static function getInstalledCultures(sfApplicationConfiguration $configuration)
{
//Get the i18n directories and check if there's any, or it's not empty:
$i18n_dirs = $configuration->getI18NGlobalDirs();
if (is_null($i18n_dirs) || empty($i18n_dirs)) {
self::setError('An error occured while opening the languages folder. Check if the i18n directory exists.');
return null;
}
$installed_cultures = array();
//Get the first one: apps/mgmt/i18n/
$i18n_dir = dir($i18n_dirs[0]);
//Get all of the subdirectories but ignore '.' and '..' directories
while (false !== ($culture_dir = $i18n_dir->read())) {
if (is_dir($i18n_dirs[0] . '/' . $culture_dir) && $culture_dir[0] != '.') {
$installed_cultures[] = $culture_dir;
}
}
return $installed_cultures;
}
示例3: getI18NGlobalDirs
/**
* Gets the i18n directories to use globally.
*
* @return array An array of i18n directories
*/
public function getI18NGlobalDirs()
{
$dirs = array();
$dirs = array_merge($dirs, array(sfConfig::get('sf_root_dir') . '/i18n'));
$dirs = array_merge($dirs, parent::getI18NGlobalDirs());
return $dirs;
}