Only load list of locale files for calculation engine if setLocale() is explicitly called

This commit is contained in:
Mark Baker 2012-12-24 15:32:17 +00:00
parent 420b344d44
commit 979aa760c0
1 changed files with 13 additions and 8 deletions

View File

@ -1681,14 +1681,6 @@ class PHPExcel_Calculation {
private function __construct() { private function __construct() {
$localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
$filename = substr($filename,strlen($localeFileDirectory)+1);
if ($filename != 'en') {
self::$_validLocaleLanguages[] = $filename;
}
}
$setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16; $setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16;
$this->_savedPrecision = ini_get('precision'); $this->_savedPrecision = ini_get('precision');
if ($this->_savedPrecision < $setPrecision) { if ($this->_savedPrecision < $setPrecision) {
@ -1703,6 +1695,16 @@ class PHPExcel_Calculation {
} }
} }
private static function _loadLocales() {
$localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
$filename = substr($filename,strlen($localeFileDirectory)+1);
if ($filename != 'en') {
self::$_validLocaleLanguages[] = $filename;
}
}
}
/** /**
* Get an instance of this class * Get an instance of this class
* *
@ -1883,6 +1885,9 @@ class PHPExcel_Calculation {
list($language) = explode('_',$locale); list($language) = explode('_',$locale);
} }
if (count(self::$_validLocaleLanguages) == 1)
self::_loadLocales();
// Test whether we have any language data for this language (any locale) // Test whether we have any language data for this language (any locale)
if (in_array($language,self::$_validLocaleLanguages)) { if (in_array($language,self::$_validLocaleLanguages)) {
// initialise language/locale settings // initialise language/locale settings