How to use the numeral.locale function in numeral

To help you get started, we’ve selected a few numeral examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikimedia / analytics-wikistats2 / src / App.vue View on Github external
setUpNumeralLocale() {
            //locale recognition, rudimentary, from navigator.language if defined
            // webpack does not have locale support out of the box
            // 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")
                }
            }
        },
github wikimedia / analytics-wikistats2 / src / App.vue View on Github external
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 () {
github pvtruong / excel-report / excelReport.js View on Github external
abbreviations: {
        thousand: 'ngàn',
        million: 'triệu',
        billion: 'tỷ',
        trillion: 'ngàn tỷ'
    },
    ordinal : function (number) {
        return number === 1 ? 'er' : 'ème';
    },
    currency: {
        symbol: 'VND'
    }
});

// switch between locales
numeral.locale('vn');
//
var moment = require('moment');
moment.locale("vi");
//
function escapeRegExp(string) {
	return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
function replaceAll(string, find, replace) {
  
  if(!string || !find) return "";
  if(underscore.isArray(replace) || underscore.isObject(replace)){
	  return string.replace(new RegExp(escapeRegExp(find), 'g'), "");
  }
  return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function fillData(zip,data,begin_row,stt_sharedString,callback){
github SmokeHouseProject / applewood / client / core.js View on Github external
changeLanguage(lang) {
        if (lang != this.i18n.getLocale()) {
            this.i18n.setLocale(lang);
            moment.locale(lang);
            numeral.locale(lang);
            localStorage.setItem('Language', lang);
        }
    }
github LiskHQ / lisk-desktop / src / utils / formattedNumber.js View on Github external
export const formatAmountBasedOnLocale = ({
  value,
  format = '0,0.[0000000000000000]',
}) => {
  numeral.locale(i18n.language);
  const amount = parseFloat(value);
  return numeral(amount).format(format);
};
github graphsense / graphsense-dashboard / src / app.js View on Github external
this.dispatcher.on('changeLocale', (locale) => {
      moment.locale(locale)
      numeral.locale(locale)
      this.locale = locale
      this.config.setLocale(locale)
      this.browser.setUpdate('locale')
      this.graph.setUpdate('layers')
    })
    this.dispatcher.on('receiveCategories', ({result}) => {
github metasfresh / metasfresh-webui-frontend / src / actions / AppActions.js View on Github external
function initNumeralLocales(lang, locale) {
  const language = lang.toLowerCase();
  const LOCAL_NUMERAL_FORMAT = {
    defaultFormat: '0,0.00[000]',
    delimiters: {
      thousands: locale.numberGroupingSeparator || ',',
      decimal: locale.numberDecimalSeparator || '.',
    },
  };

  if (typeof numeral.locales[language] === 'undefined') {
    numeral.register('locale', language, LOCAL_NUMERAL_FORMAT);
  }

  if (typeof numeral.locales[language] !== 'undefined') {
    numeral.locale(language);

    if (LOCAL_NUMERAL_FORMAT.defaultFormat) {
      numeral.defaultFormat(LOCAL_NUMERAL_FORMAT.defaultFormat);
    }
  }
}
github lloydjatkinson / vue-numeral-filter / dist / vue-numeral-filter.es.js View on Github external
install: function install(vue) {
    var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
        _ref$locale = _ref.locale,
        locale = _ref$locale === void 0 ? 'en-gb' : _ref$locale;

    numeral.locale(locale);
    vue.filter('abbreviate', abbreviate);
    vue.filter('bytes', bytes);
    vue.filter('exponential', exponential);
    vue.filter('numeral', exposedNumeral);
    vue.filter('ordinal', ordinal);
    vue.filter('percentage', percentage);
    vue.filter('separator', separator);
    vue.filter('currency', currency);
  }
};