locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
28 lines (27 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.localeconv = localeconv;
const _phpRuntimeState_ts_1 = require("../_helpers/_phpRuntimeState.js");
const setlocale_ts_1 = require("../strings/setlocale.js");
function localeconv() {
// discuss at: https://locutus.io/php/localeconv/
// original by: Brett Zamir (https://brett-zamir.me)
// example 1: setlocale('LC_ALL', 'en_US')
// example 1: localeconv()
// returns 1: {decimal_point: '.', thousands_sep: '', positive_sign: '', negative_sign: '-', int_frac_digits: 2, frac_digits: 2, p_cs_precedes: 1, p_sep_by_space: 0, n_cs_precedes: 1, n_sep_by_space: 0, p_sign_posn: 1, n_sign_posn: 1, grouping: [], int_curr_symbol: 'USD ', currency_symbol: '$', mon_decimal_point: '.', mon_thousands_sep: ',', mon_grouping: [3, 3]}
const arr = {};
// ensure setup of localization variables takes place, if not already
(0, setlocale_ts_1.setlocale)('LC_ALL', 0);
// Make copies
const numeric = (0, _phpRuntimeState_ts_1.getPhpLocaleGroup)('LC_NUMERIC', 'LC_NUMERIC');
if (!numeric) {
return arr;
}
Object.assign(arr, numeric);
const monetary = (0, _phpRuntimeState_ts_1.getPhpLocaleGroup)('LC_MONETARY', 'LC_MONETARY');
if (!monetary) {
return arr;
}
Object.assign(arr, monetary);
return arr;
}