Skip to content

Instantly share code, notes, and snippets.

@Lunberg88
Created July 16, 2020 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lunberg88/a3acee97b3fa98d3b7bf414f08ec1b16 to your computer and use it in GitHub Desktop.
Save Lunberg88/a3acee97b3fa98d3b7bf414f08ec1b16 to your computer and use it in GitHub Desktop.
// @/lang/index.js
const numberFormats = {
'en': {
currency: {
style: 'currency',
currency: 'CHF'
}
},
'de': {
currency: {
style: 'currency',
currency: 'EUR'
}
},
'fr': {
currency: {
style: 'currency',
currency: 'EUR'
}
},
'ch': {
currency: {
style: 'currency',
currency: 'CHF'
}
},
'it': {
currency: {
style: 'currency',
currency: 'EUR'
}
}
};
// @/lang/numeralLocales
export const registerNumeric = (val) => {
const locale = getLangCode();
return i18n.n(val, 'currency', locale.toLowerCase() || 'en');
};
// main.ts
Vue.prototype.$numeral = registerNumeric;
// @/components/X.vue
methods: {
totalPrice(val) {
return this.$numeral(val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment