add currency filter

This commit is contained in:
MaysWind
2020-11-08 23:16:51 +08:00
parent da4083138c
commit 2dbaabdedd
6 changed files with 54 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import settings from "../lib/settings.js";
export default function ({ i18n }, value, currencyCode) {
if (!value) {
return value;
}
value = value / 100;
const currencyDisplayMode = settings.getCurrencyDisplayMode();
if (currencyDisplayMode === 'code') {
return `${value} ${currencyCode}`;
} else if (currencyDisplayMode === 'name') {
const name = i18n.t(`currency.${currencyCode}`);
return `${value} ${name}`;
} else {
return value;
}
}