diff options
Diffstat (limited to 'vendor/commerceguys/intl')
-rw-r--r-- | vendor/commerceguys/intl/.travis.yml | 1 | ||||
-rw-r--r-- | vendor/commerceguys/intl/README.md | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | vendor/commerceguys/intl/scripts/fetch_data.sh | 0 | ||||
-rw-r--r-- | vendor/commerceguys/intl/scripts/generate_base.php | 4 | ||||
-rw-r--r-- | vendor/commerceguys/intl/scripts/generate_number_format_data.php | 6 | ||||
-rw-r--r-- | vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php | 14 | ||||
-rw-r--r-- | vendor/commerceguys/intl/src/Formatter/FormatterTrait.php | 34 | ||||
-rw-r--r-- | vendor/commerceguys/intl/src/Formatter/NumberFormatter.php | 14 | ||||
-rw-r--r-- | vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php | 46 | ||||
-rw-r--r-- | vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php | 2 |
10 files changed, 105 insertions, 20 deletions
diff --git a/vendor/commerceguys/intl/.travis.yml b/vendor/commerceguys/intl/.travis.yml index f23e9a5eb..368b63291 100644 --- a/vendor/commerceguys/intl/.travis.yml +++ b/vendor/commerceguys/intl/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 7.4 - 7.3 - 7.2 - 7.1 diff --git a/vendor/commerceguys/intl/README.md b/vendor/commerceguys/intl/README.md index 23fa51498..06235c45a 100644 --- a/vendor/commerceguys/intl/README.md +++ b/vendor/commerceguys/intl/README.md @@ -44,7 +44,7 @@ $numberFormatRepository = new NumberFormatRepository; // Options can be provided to the constructor or the // individual methods, the locale defaults to 'en' when missing. $numberFormatter = new NumberFormatter($numberFormatRepository); -echo $numberFormatter->format('1234.99'); // 123,456.99 +echo $numberFormatter->format('1234.99'); // 1,234.99 echo $numberFormatter->format('0.75', ['style' => 'percent']); // 75% $currencyRepository = new CurrencyRepository; @@ -85,6 +85,7 @@ echo $currency->getName(); // dollar des États-Unis echo $currency->getSymbol(); // $US echo $currency->getLocale(); // fr-FR +// Get all currencies, keyed by currency code. $allCurrencies = $currencyRepository->getAll(); ``` @@ -105,6 +106,7 @@ echo $language->getName(); // German $language = $languageRepository->get('de', 'fr-FR'); echo $language->getName(); // allemand +// Get all languages, keyed by language code. $allLanguages = $languageRepository->getAll(); ``` diff --git a/vendor/commerceguys/intl/scripts/fetch_data.sh b/vendor/commerceguys/intl/scripts/fetch_data.sh index 804ecc1a1..804ecc1a1 100644..100755 --- a/vendor/commerceguys/intl/scripts/fetch_data.sh +++ b/vendor/commerceguys/intl/scripts/fetch_data.sh diff --git a/vendor/commerceguys/intl/scripts/generate_base.php b/vendor/commerceguys/intl/scripts/generate_base.php index d5e18f2b6..6932b32f4 100644 --- a/vendor/commerceguys/intl/scripts/generate_base.php +++ b/vendor/commerceguys/intl/scripts/generate_base.php @@ -35,8 +35,8 @@ if (!function_exists('collator_create')) { $ignoredLocales = [ // Esperanto, Interlingua, Volapuk are made up languages. 'eo', 'ia', 'vo', - // Church Slavic, Manx, Prussian are historical languages. - 'cu', 'gv', 'prg', + // Church Slavic, Manx, Prussian, Sanskrit are historical languages. + 'cu', 'gv', 'prg', 'sa', // Valencian differs from its parent only by a single character (è/é). 'ca-ES-VALENCIA', // Africa secondary languages. diff --git a/vendor/commerceguys/intl/scripts/generate_number_format_data.php b/vendor/commerceguys/intl/scripts/generate_number_format_data.php index 0654d0ebb..2a00548cf 100644 --- a/vendor/commerceguys/intl/scripts/generate_number_format_data.php +++ b/vendor/commerceguys/intl/scripts/generate_number_format_data.php @@ -106,9 +106,15 @@ function generate_number_formats() if ($decimalSeparator != '.') { $numberFormats[$locale]['decimal_separator'] = $decimalSeparator; } + if (array_key_exists('currencyDecimal', $data['symbols-numberSystem-' . $numberingSystem])) { + $numberFormats[$locale]['decimal_currency_separator'] = $data['symbols-numberSystem-' . $numberingSystem]['currencyDecimal']; + } if ($groupingSeparator != ',') { $numberFormats[$locale]['grouping_separator'] = $groupingSeparator; } + if (array_key_exists('currencyGroup', $data['symbols-numberSystem-' . $numberingSystem])) { + $numberFormats[$locale]['grouping_currency_separator'] = $data['symbols-numberSystem-' . $numberingSystem]['currencyGroup']; + } if ($plusSign != '+') { $numberFormats[$locale]['plus_sign'] = $plusSign; } diff --git a/vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php b/vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php index 8d4d11f27..7d3b90d6e 100644 --- a/vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php +++ b/vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php @@ -238,4 +238,18 @@ class CurrencyFormatter implements CurrencyFormatterInterface throw new InvalidArgumentException(sprintf('Unrecognized currency display "%s".', $options['currency_display'])); } } + + /** + * {@inheritdoc} + */ + protected function getLocalizedSymbols(NumberFormat $numberFormat): array + { + return [ + '.' => $numberFormat->getDecimalCurrencySeparator(), + ',' => $numberFormat->getGroupingCurrencySeparator(), + '+' => $numberFormat->getPlusSign(), + '-' => $numberFormat->getMinusSign(), + '%' => $numberFormat->getPercentSign(), + ]; + } } diff --git a/vendor/commerceguys/intl/src/Formatter/FormatterTrait.php b/vendor/commerceguys/intl/src/Formatter/FormatterTrait.php index aa63c1f5f..11cdd2372 100644 --- a/vendor/commerceguys/intl/src/Formatter/FormatterTrait.php +++ b/vendor/commerceguys/intl/src/Formatter/FormatterTrait.php @@ -124,13 +124,7 @@ trait FormatterTrait $number = strtr($number, $this->digits[$numberingSystem]); } // Localize symbols. - $replacements = [ - '.' => $numberFormat->getDecimalSeparator(), - ',' => $numberFormat->getGroupingSeparator(), - '+' => $numberFormat->getPlusSign(), - '-' => $numberFormat->getMinusSign(), - '%' => $numberFormat->getPercentSign(), - ]; + $replacements = $this->getLocalizedSymbols($numberFormat); $number = strtr($number, $replacements); return $number; @@ -149,15 +143,10 @@ trait FormatterTrait */ protected function parseNumber($number, NumberFormat $numberFormat) { - $replacements = [ - $numberFormat->getGroupingSeparator() => '', - // Convert the localized symbols back to their original form. - $numberFormat->getDecimalSeparator() => '.', - $numberFormat->getPlusSign() => '+', - $numberFormat->getMinusSign() => '-', - $numberFormat->getPercentSign() => '%', - - // Strip whitespace (spaces and non-breaking spaces). + // Convert localized symbols back to their original form. + $replacements = array_flip($this->getLocalizedSymbols($numberFormat)); + // Strip whitespace (spaces and non-breaking spaces). + $replacements += [ ' ' => '', chr(0xC2) . chr(0xA0) => '', ]; @@ -168,6 +157,8 @@ trait FormatterTrait } $number = strtr($number, $replacements); + // Strip grouping separators. + $number = str_replace(',', '', $number); // Convert the accounting format for negative numbers. if (substr($number, 0, 1) == '(' && substr($number, -1, 1) == ')') { $number = '-' . str_replace(['(', ')'], '', $number); @@ -212,4 +203,15 @@ trait FormatterTrait * @return string[] The patterns, keyed by style. */ abstract protected function getAvailablePatterns(NumberFormat $numberFormat); + + /** + * Gets the localized symbols for the provided number format. + * + * Used to localize the number in localizeNumber(). + * + * @param NumberFormat $numberFormat The number format. + * + * @return array + */ + abstract protected function getLocalizedSymbols(NumberFormat $numberFormat): array; } diff --git a/vendor/commerceguys/intl/src/Formatter/NumberFormatter.php b/vendor/commerceguys/intl/src/Formatter/NumberFormatter.php index 95c9a0020..03795fe6d 100644 --- a/vendor/commerceguys/intl/src/Formatter/NumberFormatter.php +++ b/vendor/commerceguys/intl/src/Formatter/NumberFormatter.php @@ -160,4 +160,18 @@ class NumberFormatter implements NumberFormatterInterface throw new InvalidArgumentException(sprintf('Unrecognized style "%s".', $options['style'])); } } + + /** + * {@inheritdoc} + */ + protected function getLocalizedSymbols(NumberFormat $numberFormat): array + { + return [ + '.' => $numberFormat->getDecimalSeparator(), + ',' => $numberFormat->getGroupingSeparator(), + '+' => $numberFormat->getPlusSign(), + '-' => $numberFormat->getMinusSign(), + '%' => $numberFormat->getPercentSign(), + ]; + } } diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php index 156470eee..8c41a5aa8 100644 --- a/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php +++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormat.php @@ -68,6 +68,13 @@ final class NumberFormat protected $decimalSeparator = '.'; /** + * The decimal separator for currency amounts. + * + * @var string + */ + protected $decimalCurrencySeparator = '.'; + + /** * The grouping separator. * * @var string @@ -75,6 +82,13 @@ final class NumberFormat protected $groupingSeparator = ','; /** + * The grouping separator for currency amounts. + * + * @var string + */ + protected $groupingCurrencySeparator = ','; + + /** * The plus sign. * * @var string @@ -130,9 +144,19 @@ final class NumberFormat if (isset($definition['decimal_separator'])) { $this->decimalSeparator = $definition['decimal_separator']; } + if (isset($definition['decimal_currency_separator'])) { + $this->decimalCurrencySeparator = $definition['decimal_currency_separator']; + } else { + $this->decimalCurrencySeparator = $this->decimalSeparator; + } if (isset($definition['grouping_separator'])) { $this->groupingSeparator = $definition['grouping_separator']; } + if (isset($definition['grouping_currency_separator'])) { + $this->groupingCurrencySeparator = $definition['grouping_currency_separator']; + } else { + $this->groupingCurrencySeparator = $this->groupingSeparator; + } if (isset($definition['plus_sign'])) { $this->plusSign = $definition['plus_sign']; } @@ -227,7 +251,17 @@ final class NumberFormat } /** - * Gets the grouping separator. + * Gets the decimal separator for currency amounts. + * + * @return string + */ + public function getDecimalCurrencySeparator() + { + return $this->decimalCurrencySeparator; + } + + /** + * Gets the grouping separator for currency amounts. * * @return string */ @@ -237,6 +271,16 @@ final class NumberFormat } /** + * Gets the currency grouping separator. + * + * @return string + */ + public function getGroupingCurrencySeparator() + { + return $this->groupingCurrencySeparator; + } + + /** * Gets the plus sign. * * @return string diff --git a/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php index 948fa533c..987ceda89 100644 --- a/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php +++ b/vendor/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php @@ -227,6 +227,7 @@ class NumberFormatRepository implements NumberFormatRepositoryInterface 'accounting_currency_pattern' => '#,##0.00 ¤', 'decimal_separator' => ',', 'grouping_separator' => ' ', + 'grouping_currency_separator' => '.', ], 'de-CH' => [ 'currency_pattern' => '¤ #,##0.00;¤-#,##0.00', @@ -476,6 +477,7 @@ class NumberFormatRepository implements NumberFormatRepositoryInterface 'currency_pattern' => '#,##0.00 ¤', 'accounting_currency_pattern' => '#,##0.00 ¤;(#,##0.00 ¤)', 'decimal_separator' => ',', + 'decimal_currency_separator' => '.', 'grouping_separator' => ' ', ], 'fr-LU' => [ |