How to use the numeral.locales 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 elmsln / WCFactory / packages / generator-wcfactory / generators / init / templates / elements / rh-number / src / rh-number.js View on Github external
import RHElement from "../rhelement/rhelement.js";
import numeral from "numeral";

// easy aliases for common format strings
const types = {
  abbrev: "0a", // or 'approx'?
  ordinal: "0o",
  percent: "0%",
  bytes: "0[.][00] ib",
  e: "0[.00]e+0",
  thousands: "0,0[.00]"
};

// use thin spaces to separate thousands chunks
// debugger;
numeral.locales.en.delimiters.thousands = " ";

class RhNumber extends RHElement {
  static get tag() {
    return "rh-number";
  }

  get styleUrl() {
    return "rh-number.scss";
  }

  get templateUrl() {
    return "rh-number.html";
  }

  static get observedAttributes() {
    return ["number", "format", "type"];
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 oroinc / platform / src / Oro / Bundle / LocaleBundle / Resources / public / js / numeral-l10n.js View on Github external
define(function(require) {
    'use strict';

    const numeral = require('numeral');
    const localeSettings = require('./locale-settings');
    const currencySettings = localeSettings.getNumberFormats('currency');

    numeral.locales[localeSettings.getLocale().toLowerCase()] = {
        delimiters: {
            thousands: currencySettings.grouping_separator_symbol,
            decimal: currencySettings.decimal_separator_symbol
        },
        abbreviations: {
            thousand: 'k',
            million: 'm',
            billion: 'b',
            trillion: 't'
        },
        ordinal: function(number) {
            const b = number % 10;
            return (~~(number % 100 / 10) === 1) ? 'th'
                : (b === 1) ? 'st'
                    : (b === 2) ? 'nd'
                        : (b === 3) ? 'rd' : 'th';
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);
    }
  }
}