From 979aa760c0d3c2a229b9357168b4638058f3900a Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 24 Dec 2012 15:32:17 +0000 Subject: [PATCH] Only load list of locale files for calculation engine if setLocale() is explicitly called --- Classes/PHPExcel/Calculation.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index 2fc63e58..70f8d124 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -1681,14 +1681,6 @@ class PHPExcel_Calculation { 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; $this->_savedPrecision = ini_get('precision'); 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 * @@ -1883,6 +1885,9 @@ class PHPExcel_Calculation { list($language) = explode('_',$locale); } + if (count(self::$_validLocaleLanguages) == 1) + self::_loadLocales(); + // Test whether we have any language data for this language (any locale) if (in_array($language,self::$_validLocaleLanguages)) { // initialise language/locale settings