*
* @return string
*
+ * @throws \CRM_Core_Exception
+ *
* @noinspection PhpDocMissingThrowsInspection
* @noinspection PhpUnhandledExceptionInspection
*/
$currency = Civi::settings()->get('defaultCurrency');
}
if (!isset($locale)) {
- $locale = CRM_Core_I18n::getLocale();
+ $locale = Civi::settings()->get('format_locale') ?? CRM_Core_I18n::getLocale();
}
$money = Money::of($amount, $currency, NULL, RoundingMode::HALF_UP);
$formatter = $this->getMoneyFormatter($currency, $locale);
* add any padding.
*
* @return string
+ * @throws \CRM_Core_Exception
*/
public function number($amount, ?string $locale = NULL, array $attributes = [
NumberFormatter::MIN_FRACTION_DIGITS => 0,
* we are looking at how to manage an 'opt in'
*/
protected function isUseSeparatorSettings(): bool {
- return !CRM_Utils_Constant::value('IGNORE_SEPARATOR_CONFIG');
+ return !Civi::settings()->get('format_locale') && !CRM_Utils_Constant::value('IGNORE_SEPARATOR_CONFIG');
}
/**
}
// Verify the amount is a number or numeric string/object.
// We cast to string because it can be a BigDecimal object.
- elseif ($amount === TRUE || !is_numeric((string) $amount)) {
+ if ($amount === TRUE || !is_numeric((string) $amount)) {
throw new \CRM_Core_Exception('Invalid value for type money');
}
return (string) $amount;