Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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")
}
}
},
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 () {
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){
changeLanguage(lang) {
if (lang != this.i18n.getLocale()) {
this.i18n.setLocale(lang);
moment.locale(lang);
numeral.locale(lang);
localStorage.setItem('Language', lang);
}
}
export const formatAmountBasedOnLocale = ({
value,
format = '0,0.[0000000000000000]',
}) => {
numeral.locale(i18n.language);
const amount = parseFloat(value);
return numeral(amount).format(format);
};
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}) => {
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);
}
}
}
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);
}
};