Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import 'numeral/locales'
Logger.setLogLevel(IS_DEV ? Logger.LogLevels.DEBUG : Logger.LogLevels.ERROR) // eslint-disable-line no-undef
const getNavigatorLanguage = () => {
if (navigator.languages && navigator.languages.length) {
return navigator.languages[0]
} else {
return navigator.userLanguage || navigator.language || navigator.browserLanguage || 'en'
}
}
const locale = getNavigatorLanguage().split('-')[0]
numeral.locale(locale)
try {
numeral.localeData(locale)
} catch (e) {
console.warn(`Couldn't find locale '${locale}', falling back to 'en'`)
numeral.locale('en')
}
if (locale === 'de') {
// overwrite locale format
let de = numeral.localeData(locale)
de.delimiters.thousands = '.'
}
moment.locale(locale)
const timezone = jstz.determine().name()
moment.tz.setDefault(timezone)
let model = new Start(locale)
return navigator.userLanguage || navigator.language || navigator.browserLanguage || 'en'
}
}
const locale = getNavigatorLanguage().split('-')[0]
numeral.locale(locale)
try {
numeral.localeData(locale)
} catch (e) {
console.warn(`Couldn't find locale '${locale}', falling back to 'en'`)
numeral.locale('en')
}
if (locale === 'de') {
// overwrite locale format
let de = numeral.localeData(locale)
de.delimiters.thousands = '.'
}
moment.locale(locale)
const timezone = jstz.determine().name()
moment.tz.setDefault(timezone)
let model = new Start(locale)
model.render(document.body)
// but numeral locales are 8k compressed thus importing them all
if (navigator.language){
var locale = navigator.language.toLowerCase();
numeral.locale(locale);
// it might not exist as instead of "en-us"
// numeral defines "en", live with this for now
// change later to use navigators convention http://www.ietf.org/rfc/bcp/bcp47.txt
if (!numeral.localeData()){
// try again with an abbreviated version
numeral.locale(locale.split( '-' )[0]);
}
if (!numeral.localeData()){
// set to english, browser might be set
// to a locale numeral does not have
numeral.locale("en-gb")
}
}
},
handleResize () {
function numberFormat(value, decimalPoints, decimalDelimiter, thousandsDelimiter) {
// Temporarily update locale data (restore defaults after formatting)
const locale = numeral.localeData();
const savedDelimiters = locale.delimiters;
// Mimic old behavior - AngularJS `number` filter defaults:
// - `,` as thousands delimiter
// - `.` as decimal delimiter
// - three decimal points
locale.delimiters = {
thousands: ',',
decimal: '.',
};
let formatString = '0,0.000';
if (
(Number.isFinite(decimalPoints) && (decimalPoints >= 0)) ||
decimalDelimiter ||
thousandsDelimiter
) {
format(amount, decimals = 0, currencyLocale = null) {
const lang = currencyLocale || channel.request('currencyLocale');
let formatStr = '$0,0';
let currencyEnd = false;
if (lang) {
numeral.locale(lang);
let language = numeral.localeData();
if (language.format) {
formatStr = language.format;
}
}
if (formatStr.charAt(formatStr.length - 1) === '$') {
currencyEnd = true;
formatStr = formatStr.slice(0, -1);
}
for (let i = 0; i < decimals; i++) {
if (i === 0) {
formatStr += '.';
}
public render() {
numeral.localeData("en"); //
const { className } = this.props;
const value = numeral(this.props.value);
const compactValue = this.stripTrailingZeros(value.format("0a.0"));
const fullValue = value.format();
const classes = numberFormattedClasses();
const Tag = fullValue === compactValue ? `span` : `abbr`;
return (
{compactValue}
);
}
'use strict';
const Moment = require('moment');
const Json2Xml = require('json2xml');
const HandlebarsIntl = require('handlebars-intl');
const Helpers = require('handlebars-helpers');
const Numeral = require('numeral');
const _ = require('lodash');
_.assign(Numeral.localeData('en'), {
abbreviations: {
thousand: "K",
million: "M",
billion: "B",
trillion: "T"
}
});
const buildListOfWords = (words, separator) => {
if (!Array.isArray(words)){
return words;
}
if (words.length === 1){
return words[0];
}