mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This should fix locale information for specific languages. It’s not perfect yet though.
This commit is contained in:
parent
8a00101470
commit
8208d44466
@ -23,7 +23,6 @@ use Illuminate\Contracts\Auth\Guard;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
use NumberFormatter;
|
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
@ -111,20 +110,43 @@ class Range
|
|||||||
$monthAndDayFormat = (string)trans('config.month_and_day');
|
$monthAndDayFormat = (string)trans('config.month_and_day');
|
||||||
$dateTimeFormat = (string)trans('config.date_time');
|
$dateTimeFormat = (string)trans('config.date_time');
|
||||||
$defaultCurrency = Amount::getDefaultCurrency();
|
$defaultCurrency = Amount::getDefaultCurrency();
|
||||||
|
$localeconv = localeconv();
|
||||||
|
|
||||||
// change localeconv to a new array:
|
// decimal places is overruled by TransactionCurrency
|
||||||
$numberFormatter = numfmt_create($lang, NumberFormatter::CURRENCY);
|
$localeconv['frac_digits'] = $defaultCurrency->decimal_places;
|
||||||
$localeconv = [
|
$positiveSpace = ' ';
|
||||||
'mon_decimal_point' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)),
|
$negativeSpace = ' ';
|
||||||
'mon_thousands_sep' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL)),
|
// positive number:
|
||||||
'frac_digits' => $defaultCurrency->decimal_places,
|
if (!$localeconv['p_sep_by_space']) {
|
||||||
|
$positiveSpace = '';
|
||||||
|
}
|
||||||
|
// negative number:
|
||||||
|
if (!$localeconv['n_sep_by_space']) {
|
||||||
|
$negativeSpace = '';
|
||||||
|
}
|
||||||
|
// by default, put symbols before:
|
||||||
|
$accounting = [
|
||||||
|
'pos' => '%s' . $positiveSpace . '%v',
|
||||||
|
'neg' => '%s' . $negativeSpace . '-%v',
|
||||||
|
'zero' => '%s' . $positiveSpace . '%v',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// but might be after:
|
||||||
|
if (!$localeconv['n_cs_precedes']) {
|
||||||
|
$accounting['neg'] = '-%v' . $negativeSpace . '%s';
|
||||||
|
}
|
||||||
|
if (!$localeconv['p_cs_precedes']) {
|
||||||
|
$accounting['pos'] = '%v' . $negativeSpace . '%s';
|
||||||
|
$accounting['zero'] = '%v' . $negativeSpace . '%s';
|
||||||
|
}
|
||||||
|
|
||||||
View::share('monthFormat', $monthFormat);
|
View::share('monthFormat', $monthFormat);
|
||||||
View::share('monthAndDayFormat', $monthAndDayFormat);
|
View::share('monthAndDayFormat', $monthAndDayFormat);
|
||||||
View::share('dateTimeFormat', $dateTimeFormat);
|
View::share('dateTimeFormat', $dateTimeFormat);
|
||||||
View::share('language', $lang);
|
View::share('language', $lang);
|
||||||
View::share('localeconv', $localeconv);
|
View::share('localeconv', $localeconv);
|
||||||
View::share('defaultCurrency', $defaultCurrency);
|
View::share('defaultCurrency', $defaultCurrency);
|
||||||
|
View::share('accountingConfig', $accounting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
/** global: moment, dateRangeConfig, accounting, currencySymbol, mon_decimal_point, frac_digits, showFullList, showOnlyTop, mon_thousands_sep */
|
/** global: moment, accountingConfig, dateRangeConfig, accounting, currencySymbol, mon_decimal_point, frac_digits, showFullList, showOnlyTop, mon_thousands_sep */
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
@ -112,7 +112,7 @@ function currencySelect(e) {
|
|||||||
accounting.settings = {
|
accounting.settings = {
|
||||||
currency: {
|
currency: {
|
||||||
symbol: currencySymbol, // default currency symbol is '$'
|
symbol: currencySymbol, // default currency symbol is '$'
|
||||||
format: "%s %v", // controls output: %s = symbol, %v = value/number (can be object: see below)
|
format: accountingConfig, // controls output: %s = symbol, %v = value/number (can be object: see below)
|
||||||
decimal: mon_decimal_point, // decimal point separator
|
decimal: mon_decimal_point, // decimal point separator
|
||||||
thousand: mon_thousands_sep, // thousands separator
|
thousand: mon_thousands_sep, // thousands separator
|
||||||
precision: frac_digits // decimal places
|
precision: frac_digits // decimal places
|
||||||
|
@ -208,6 +208,7 @@
|
|||||||
var noDataForChart = '{{ trans('firefly.no_data_for_chart')|escape }}';
|
var noDataForChart = '{{ trans('firefly.no_data_for_chart')|escape }}';
|
||||||
var showFullList = '{{ trans('firefly.show_full_list') }}';
|
var showFullList = '{{ trans('firefly.show_full_list') }}';
|
||||||
var showOnlyTop = '{{ trans('firefly.show_only_top',{number:listLength}) }}';
|
var showOnlyTop = '{{ trans('firefly.show_only_top',{number:listLength}) }}';
|
||||||
|
var accountingConfig = {{ accountingConfig|json_encode|raw }};
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user