Skip to content

Commit

Permalink
Only load list of locale files for calculation engine if setLocale() …
Browse files Browse the repository at this point in the history
…is explicitly called
  • Loading branch information
Mark Baker committed Dec 24, 2012
1 parent 420b344 commit 979aa76
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Classes/PHPExcel/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -1703,6 +1695,16 @@ public function __destruct() {
}
}

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
*
Expand Down Expand Up @@ -1883,6 +1885,9 @@ public function setLocale($locale='en_us') {
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
Expand Down

0 comments on commit 979aa76

Please sign in to comment.