How to use the numeral.register 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 vueblocks / ve-charts / src / utils / formatZhNumber.js View on Github external
import numeral from 'numeral'

numeral.register('format', 'zh-number', {
  regexps: {
    format: /(zh)/,
    unformat: /(zh)/
  },
  format: function (value, format, roundingFunction) {
    // 判断是否有空格
    const space = numeral._.includes(format, ' zh') ? ' ' : ''
    // match 数据格式
    const precision = format.match(/\d.\d+/)
    let digits
    if (precision) {
      // 确定小数点后几位小数
      digits = precision[0].split('.')[1].length
    }
    // check for space before zh
    format = format.replace(/\s?\zh/, '');
github instructure / instructure-ui / packages / ui-utils / src / i18n / locales / sv.js View on Github external
import numeral from 'numeral'

// referenced from https://github.com/adamwdraper/Numeral-js/pull/534/files
numeral.register('locale', 'sv', {
  delimiters: {
    thousands: ' ',
    decimal: ','
  },
  abbreviations: {
    thousand: 'k',
    million: 'm',
    billion: 'md',
    trillion: 'bn'
  },
  // http://www.unicode.org/cldr/charts/31/verify/numbers/sv.html
  ordinal: function (number) {
    const b = number % 10
    if ((b === 1 || b === 2) && ((number % 100) !== 11 && (number % 100) !== 12)) {
      return ':a'
    }
github yyssc / ssc-grid / src / GridRow.js View on Github external
import 'moment/locale/zh-cn';

// 使用numeral对单元格中的数字进行格式化
import numeral from 'numeral';

// YBZSAAS-461
// IE11不支持Array.prototype.find()
import 'core-js/fn/array/find';

// 对MouseEvent进行定义,需要放在全局环境中,方便形成jsdoc文档
/**
 * @typedef {Object} MouseEvent
 */

// load a locale
numeral.register('locale', 'chs', {
  delimiters: {
    thousands: ',',
    decimal: '.'
  },
  abbreviations: {
    thousand: '千',
    million: '百万',
    billion: '十亿',
    trillion: '兆'
  },
  ordinal: (/* number */) => {
    return '.';
  },
  currency: {
    symbol: '¥'
  }
github pvtruong / excel-report / excelReport.js View on Github external
var nodezip = require("node-zip");
var eletree = require("elementtree");
var fs = require("fs");
var underscore = require("underscore");
var numeral = require('numeral');
var async = require("async");
// load a locale
numeral.register('locale', 'vn', {
    delimiters: {
        thousands: '.',
        decimal: ','
    },
    abbreviations: {
        thousand: 'ngàn',
        million: 'triệu',
        billion: 'tỷ',
        trillion: 'ngàn tỷ'
    },
    ordinal : function (number) {
        return number === 1 ? 'er' : 'ème';
    },
    currency: {
        symbol: 'VND'
    }
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 BedeGaming / orchestra / src / helpers / currency.js View on Github external
addLocale(code, language) {
    numeral.register('locale', code, language);
  }