mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
support currency symbol
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import currency from "../consts/currency.js";
|
||||
import settings from "../lib/settings.js";
|
||||
import utils from "../lib/utils.js";
|
||||
|
||||
@@ -49,6 +50,20 @@ export default function ({i18n}, value, currencyCode) {
|
||||
} else if (currencyDisplayMode === 'name') {
|
||||
const currencyName = i18n.t(`currency.${currencyCode}`);
|
||||
return `${value} ${currencyName}`;
|
||||
} else if (currencyDisplayMode === 'symbol') {
|
||||
const currencyInfo = currency.all[currencyCode];
|
||||
let currencySymbol = currency.defaultCurrencySymbol;
|
||||
|
||||
if (currencyInfo && currencyInfo.symbol) {
|
||||
currencySymbol = currencyInfo.symbol;
|
||||
} else if (currencyInfo && currencyInfo.code) {
|
||||
currencySymbol = currencyInfo.code;
|
||||
}
|
||||
|
||||
return i18n.t('format.currency.symbol', {
|
||||
amount: value,
|
||||
symbol: currencySymbol
|
||||
});
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user