support currency unit name

This commit is contained in:
MaysWind
2024-08-03 16:11:17 +08:00
parent c91a56547f
commit c57f17233a
7 changed files with 1374 additions and 490 deletions
+8 -2
View File
@@ -15,8 +15,10 @@ const (
CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT_WITHOUT_SPACE CurrencyDisplayType = 5
CURRENCY_DISPLAY_TYPE_CODE_BEFORE_AMOUNT CurrencyDisplayType = 6
CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT CurrencyDisplayType = 7
CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT CurrencyDisplayType = 8
CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT CurrencyDisplayType = 9
CURRENCY_DISPLAY_TYPE_UNIT_BEFORE_AMOUNT CurrencyDisplayType = 8
CURRENCY_DISPLAY_TYPE_UNIT_AFTER_AMOUNT CurrencyDisplayType = 9
CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT CurrencyDisplayType = 10
CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT CurrencyDisplayType = 11
CURRENCY_DISPLAY_TYPE_INVALID CurrencyDisplayType = 255
)
@@ -39,6 +41,10 @@ func (d CurrencyDisplayType) String() string {
return "Code Before Amount"
case CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT:
return "Code After Amount"
case CURRENCY_DISPLAY_TYPE_UNIT_BEFORE_AMOUNT:
return "Unit Before Amount"
case CURRENCY_DISPLAY_TYPE_UNIT_AFTER_AMOUNT:
return "Unit After Amount"
case CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT:
return "Name Before Amount"
case CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT:
+1 -1
View File
@@ -191,7 +191,7 @@ type UserProfileUpdateRequest struct {
DecimalSeparator *DecimalSeparator `json:"decimalSeparator" binding:"omitempty,min=0,max=3"`
DigitGroupingSymbol *DigitGroupingSymbol `json:"digitGroupingSymbol" binding:"omitempty,min=0,max=4"`
DigitGrouping *DigitGroupingType `json:"digitGrouping" binding:"omitempty,min=0,max=2"`
CurrencyDisplayType *CurrencyDisplayType `json:"currencyDisplayType" binding:"omitempty,min=0,max=9"`
CurrencyDisplayType *CurrencyDisplayType `json:"currencyDisplayType" binding:"omitempty,min=0,max=11"`
ExpenseAmountColor *AmountColorType `json:"expenseAmountColor" binding:"omitempty,min=0,max=4"`
IncomeAmountColor *AmountColorType `json:"incomeAmountColor" binding:"omitempty,min=0,max=4"`
}
+340 -162
View File
File diff suppressed because it is too large Load Diff
+5 -3
View File
@@ -2,7 +2,7 @@ import currencyConstants from '@/consts/currency.js';
import { isString, isNumber } from './common.js';
export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyName, isPlural) {
export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural) {
if (isNumber(value)) {
value = value.toString();
}
@@ -11,7 +11,7 @@ export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, c
return value;
}
const symbol = getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyName, isPlural);
const symbol = getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
if (!symbol) {
return value;
@@ -30,7 +30,7 @@ export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, c
return value;
}
export function getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyName, isPlural) {
export function getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural) {
if (!currencyDisplayType) {
return null;
}
@@ -53,6 +53,8 @@ export function getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, cur
}
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Code) {
symbol = currencyCode;
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Unit) {
symbol = currencyUnit;
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Name) {
symbol = currencyName;
}
+19 -3
View File
@@ -201,7 +201,21 @@ function getDefaultFirstDayOfWeek(translateFn) {
}
function getCurrencyName(currencyCode, translateFn) {
return translateFn(`currency.${currencyCode}`);
return translateFn(`currency.name.${currencyCode}`);
}
function getCurrencyUnitName(currencyCode, isPlural, translateFn) {
const currencyInfo = currencyConstants.all[currencyCode];
if (currencyInfo && currencyInfo.unit) {
if (isPlural) {
return translateFn(`currency.unit.${currencyInfo.unit}.plural`);
} else {
return translateFn(`currency.unit.${currencyInfo.unit}.normal`);
}
}
return '';
}
function getAllMeridiemIndicatorNames(translateFn) {
@@ -886,8 +900,9 @@ function getFormatedAmountWithCurrency(value, currencyCode, translateFn, userSto
currencyDisplayType = getCurrentCurrencyDisplayType(translateFn, userStore);
}
const currencyUnit = getCurrencyUnitName(currencyCode, isPlural, translateFn);
const currencyName = getCurrencyName(currencyCode, translateFn);
return appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyName, isPlural);
return appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
}
function getFormatedExchangeRateAmount(value, translateFn, userStore) {
@@ -902,8 +917,9 @@ function getAdaptiveAmountRate(amount1, amount2, fromExchangeRate, toExchangeRat
function getAmountPrependAndAppendText(currencyCode, userStore, settingsStore, isPlural, translateFn) {
const currencyDisplayType = getCurrentCurrencyDisplayType(translateFn, userStore);
const currencyUnit = getCurrencyUnitName(currencyCode, isPlural, translateFn);
const currencyName = getCurrencyName(currencyCode, translateFn);
return getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyName, isPlural);
return getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
}
function getAllExpenseIncomeAmountColors(translateFn, expenseOrIncome) {
+341
View File
@@ -330,6 +330,7 @@ export default {
'Kiritimati Island': 'Kiritimati Island',
},
'currency': {
'name': {
'AED': 'United Arab Emirates Dirham',
'AFN': 'Afghan Afghani',
'ALL': 'Albanian Lek',
@@ -490,6 +491,345 @@ export default {
'ZWG': 'Zimbabwe Gold',
'ZWL': 'Zimbabwean Dollar',
},
'unit': {
'Afghani': {
'normal': 'Afghani',
'plural': 'Afghanis'
},
'Ariary': {
'normal': 'Ariary',
'plural': 'Ariary'
},
'Baht': {
'normal': 'Baht',
'plural': 'Baht'
},
'Balboa': {
'normal': 'Balboa',
'plural': 'Balboas'
},
'Birr': {
'normal': 'Birr',
'plural': 'Birrs'
},
'Bolivar': {
'normal': 'Bolívar',
'plural': 'Bolívares'
},
'Boliviano': {
'normal': 'Boliviano',
'plural': 'Bolivianos'
},
'Cedi': {
'normal': 'Cedi',
'plural': 'Cedis'
},
'Colon': {
'normal': 'Colon',
'plural': 'Colones'
},
'Cordoba': {
'normal': 'Córdoba',
'plural': 'Córdobas'
},
'Dalasi': {
'normal': 'Dalasi',
'plural': 'Dalasis'
},
'Denar': {
'normal': 'Denar',
'plural': 'Denari'
},
'Dinar': {
'normal': 'Dinar',
'plural': 'Dinars'
},
'Dirham': {
'normal': 'Dirham',
'plural': 'Dirhams'
},
'Dobra': {
'normal': 'Dobra',
'plural': 'Dobras'
},
'Dollar': {
'normal': 'Dollar',
'plural': 'Dollars'
},
'Dong': {
'normal': 'Dong',
'plural': 'Dong'
},
'Dram': {
'normal': 'Dram',
'plural': 'Drams'
},
'Escudo': {
'normal': 'Escudo',
'plural': 'Escudos'
},
'Euro': {
'normal': 'Euro',
'plural': 'Euros'
},
'Florin': {
'normal': 'Florin',
'plural': 'Florin'
},
'Forint': {
'normal': 'Forint',
'plural': 'Forint'
},
'Franc': {
'normal': 'Franc',
'plural': 'Francs'
},
'Gourde': {
'normal': 'Gourde',
'plural': 'Gourdes'
},
'Guarani': {
'normal': 'Guaraní',
'plural': 'Guaraníes'
},
'Guilder': {
'normal': 'Guilder',
'plural': 'Guilders'
},
'Hryvnia': {
'normal': 'Hryvnia',
'plural': 'Hryvni'
},
'Kina': {
'normal': 'Kina',
'plural': 'Kina'
},
'Kip': {
'normal': 'Kip',
'plural': 'Kip'
},
'Koruna': {
'normal': 'Koruna',
'plural': 'Korunas'
},
'Krona': {
'normal': 'Krona',
'plural': 'Kronor'
},
'Krone': {
'normal': 'Krone',
'plural': 'Kroner'
},
'Kwacha': {
'normal': 'Kwacha',
'plural': 'Kwachas'
},
'Kwanza': {
'normal': 'Kwanza',
'plural': 'Kwanzas'
},
'Kyat': {
'normal': 'Kyat',
'plural': 'Kyats'
},
'Lari': {
'normal': 'Lari',
'plural': 'Lari'
},
'Lek': {
'normal': 'Lek',
'plural': 'Lekë'
},
'Lempira': {
'normal': 'Lempira',
'plural': 'Lempiras'
},
'Leone': {
'normal': 'Leone',
'plural': 'Leones'
},
'Leu': {
'normal': 'Leu',
'plural': 'Lei'
},
'Lev': {
'normal': 'Lev',
'plural': 'Leva'
},
'Lilangeni': {
'normal': 'Lilangeni',
'plural': 'Emalangeni'
},
'Lira': {
'normal': 'Lira',
'plural': 'Liralar'
},
'Loti': {
'normal': 'Loti',
'plural': 'Maloti'
},
'Manat': {
'normal': 'Manat',
'plural': 'Manats'
},
'Mark': {
'normal': 'Mark',
'plural': 'Marks'
},
'Metical': {
'normal': 'Metical',
'plural': 'Meticais'
},
'Naira': {
'normal': 'Naira',
'plural': 'Naira'
},
'Nakfa': {
'normal': 'Nakfa',
'plural': 'Nakfas'
},
'Ngultrum': {
'normal': 'Ngultrum',
'plural': 'Ngultrums'
},
'Ouguiya': {
'normal': 'Ouguiya',
'plural': 'Ouguiya'
},
'Paanga': {
'normal': 'Paʻanga',
'plural': 'Paʻanga'
},
'Pataca': {
'normal': 'Pataca',
'plural': 'Patacas'
},
'Peso': {
'normal': 'Peso',
'plural': 'Pesos'
},
'Pound': {
'normal': 'Pound',
'plural': 'Pounds'
},
'Pula': {
'normal': 'Pula',
'plural': 'Pula'
},
'Quetzal': {
'normal': 'Quetzal',
'plural': 'Quetzales'
},
'Rand': {
'normal': 'Rand',
'plural': 'Rand'
},
'Real': {
'normal': 'Real',
'plural': 'Reais'
},
'Rial': {
'normal': 'Rial',
'plural': 'Rials'
},
'Riel': {
'normal': 'Riel',
'plural': 'Riels'
},
'Ringgit': {
'normal': 'Ringgit',
'plural': 'Ringgit'
},
'Riyal': {
'normal': 'Riyal',
'plural': 'Riyals'
},
'Ruble': {
'normal': 'Ruble',
'plural': 'Rubles'
},
'Rufiyaa': {
'normal': 'Rufiyaa',
'plural': 'Rufiyaa'
},
'Rupee': {
'normal': 'Rupee',
'plural': 'Rupees'
},
'Rupiah': {
'normal': 'Rupiah',
'plural': 'Rupiah'
},
'Shekel': {
'normal': 'Shekel',
'plural': 'Shekels'
},
'Shilling': {
'normal': 'Shilling',
'plural': 'Shillings'
},
'Sol': {
'normal': 'Sol',
'plural': 'Soles'
},
'Som': {
'normal': 'Som',
'plural': 'Som'
},
'Somoni': {
'normal': 'Somoni',
'plural': 'Somoni'
},
'Sucre': {
'normal': 'Sucre',
'plural': 'Sucre'
},
'Sum': {
'normal': 'Sum',
'plural': 'Sum'
},
'Taka': {
'normal': 'Taka',
'plural': 'Takas'
},
'Tala': {
'normal': 'Tālā',
'plural': 'Tālā'
},
'Tenge': {
'normal': 'Tenge',
'plural': 'Tenge'
},
'Tugrik': {
'normal': 'Tögrög',
'plural': 'Tögrög'
},
'Vatu': {
'normal': 'Vatu',
'plural': 'Vatu'
},
'Won': {
'normal': 'Won',
'plural': 'Won'
},
'Yen': {
'normal': 'Yen',
'plural': 'Yen'
},
'Yuan': {
'normal': 'Yuan',
'plural': 'Yuan'
},
'ZiG': {
'normal': 'ZiG',
'plural': 'ZiG'
},
'Zloty': {
'normal': 'Złoty',
'plural': 'Złoty'
}
}
},
'category': {
'Food & Drink': 'Food & Drink',
'Food': 'Food',
@@ -1131,6 +1471,7 @@ export default {
'Auto-update Exchange Rates Data': 'Auto-update Exchange Rates Data',
'Currency Display Mode': 'Currency Display Mode',
'Currency Code': 'Currency Code',
'Currency Unit': 'Currency Unit',
'Currency Name': 'Currency Name',
'Currency Symbol': 'Currency Symbol',
'Expense Amount Color': 'Expense Amount Color',
+341
View File
@@ -330,6 +330,7 @@ export default {
'Kiritimati Island': '圣诞岛',
},
'currency': {
'name': {
'AED': '阿联酋迪拉姆',
'AFN': '阿富汗尼',
'ALL': '阿尔巴尼亚列克',
@@ -490,6 +491,345 @@ export default {
'ZWG': '津巴布韦金',
'ZWL': '津巴布韦元',
},
'unit': {
'Afghani': {
'normal': '阿富汗尼',
'plural': '阿富汗尼'
},
'Ariary': {
'normal': '阿里亚里',
'plural': '阿里亚里'
},
'Baht': {
'normal': '泰铢',
'plural': '泰铢'
},
'Balboa': {
'normal': '巴波亚',
'plural': '巴波亚'
},
'Birr': {
'normal': '比亚比尔',
'plural': '比亚比尔'
},
'Bolivar': {
'normal': '玻利瓦尔',
'plural': '玻利瓦尔'
},
'Boliviano': {
'normal': '玻利维亚诺',
'plural': '玻利维亚诺'
},
'Cedi': {
'normal': '塞地',
'plural': '塞地'
},
'Colon': {
'normal': '科朗',
'plural': '科朗'
},
'Cordoba': {
'normal': '科多巴',
'plural': '科多巴'
},
'Dalasi': {
'normal': '达拉西',
'plural': '达拉西'
},
'Denar': {
'normal': '代纳尔',
'plural': '代纳尔'
},
'Dinar': {
'normal': '第纳尔',
'plural': '第纳尔'
},
'Dirham': {
'normal': '迪拉姆',
'plural': '迪拉姆'
},
'Dobra': {
'normal': '多布拉',
'plural': '多布拉'
},
'Dollar': {
'normal': '元',
'plural': '元'
},
'Dong': {
'normal': '盾',
'plural': '盾'
},
'Dram': {
'normal': '德拉姆',
'plural': '德拉姆'
},
'Escudo': {
'normal': '埃斯库多',
'plural': '埃斯库多'
},
'Euro': {
'normal': '欧元',
'plural': '欧元'
},
'Florin': {
'normal': '弗罗林',
'plural': '弗罗林'
},
'Forint': {
'normal': '福林',
'plural': '福林'
},
'Franc': {
'normal': '法郎',
'plural': '法郎'
},
'Gourde': {
'normal': '古德',
'plural': '古德'
},
'Guarani': {
'normal': '瓜拉尼',
'plural': '瓜拉尼'
},
'Guilder': {
'normal': '盾',
'plural': '盾'
},
'Hryvnia': {
'normal': '格里夫尼亚',
'plural': '格里夫尼亚'
},
'Kina': {
'normal': '基那',
'plural': '基那'
},
'Kip': {
'normal': '基普',
'plural': '基普'
},
'Koruna': {
'normal': '克朗',
'plural': '克朗'
},
'Krona': {
'normal': '克朗',
'plural': '克朗'
},
'Krone': {
'normal': '克朗',
'plural': '克朗'
},
'Kwacha': {
'normal': '克瓦查',
'plural': '克瓦查'
},
'Kwanza': {
'normal': '宽扎',
'plural': '宽扎'
},
'Kyat': {
'normal': '元',
'plural': '元'
},
'Lari': {
'normal': '拉里',
'plural': '拉里'
},
'Lek': {
'normal': '列克',
'plural': '列克'
},
'Lempira': {
'normal': '伦皮拉',
'plural': '伦皮拉'
},
'Leone': {
'normal': '利昂',
'plural': '利昂'
},
'Leu': {
'normal': '列伊',
'plural': '列伊'
},
'Lev': {
'normal': '列弗',
'plural': '列弗'
},
'Lilangeni': {
'normal': '里兰吉尼',
'plural': '里兰吉尼'
},
'Lira': {
'normal': '里拉',
'plural': '里拉'
},
'Loti': {
'normal': '洛蒂',
'plural': '洛蒂'
},
'Manat': {
'normal': '马纳特',
'plural': '马纳特'
},
'Mark': {
'normal': '马克',
'plural': '马克'
},
'Metical': {
'normal': '梅蒂卡尔',
'plural': '梅蒂卡尔'
},
'Naira': {
'normal': '奈拉',
'plural': '奈拉'
},
'Nakfa': {
'normal': '纳克法',
'plural': '纳克法'
},
'Ngultrum': {
'normal': '努扎姆',
'plural': '努扎姆'
},
'Ouguiya': {
'normal': '乌吉亚',
'plural': '乌吉亚'
},
'Paanga': {
'normal': '潘加',
'plural': '潘加'
},
'Pataca': {
'normal': '元',
'plural': '元'
},
'Peso': {
'normal': '比索',
'plural': '比索'
},
'Pound': {
'normal': '镑',
'plural': '镑'
},
'Pula': {
'normal': '纳普拉',
'plural': '纳普拉'
},
'Quetzal': {
'normal': '格查尔',
'plural': '格查尔'
},
'Rand': {
'normal': '兰特',
'plural': '兰特'
},
'Real': {
'normal': '雷亚尔',
'plural': '雷亚尔'
},
'Rial': {
'normal': '里亚尔',
'plural': '里亚尔'
},
'Riel': {
'normal': '瑞尔',
'plural': '瑞尔'
},
'Ringgit': {
'normal': '林吉特',
'plural': '林吉特'
},
'Riyal': {
'normal': '里亚尔',
'plural': '里亚尔'
},
'Ruble': {
'normal': '卢布',
'plural': '卢布'
},
'Rufiyaa': {
'normal': '拉菲亚',
'plural': '拉菲亚'
},
'Rupee': {
'normal': '卢比',
'plural': '卢比'
},
'Rupiah': {
'normal': '卢比',
'plural': '卢比'
},
'Shekel': {
'normal': '谢克尔',
'plural': '谢克尔'
},
'Shilling': {
'normal': '先令',
'plural': '先令'
},
'Sol': {
'normal': '索尔',
'plural': '索尔'
},
'Som': {
'normal': '索姆',
'plural': '索姆'
},
'Somoni': {
'normal': '索莫尼',
'plural': '索莫尼'
},
'Sucre': {
'normal': '苏克雷',
'plural': '苏克雷'
},
'Sum': {
'normal': '苏姆',
'plural': '苏姆'
},
'Taka': {
'normal': '塔卡',
'plural': '塔卡'
},
'Tala': {
'normal': '塔拉',
'plural': '塔拉'
},
'Tenge': {
'normal': '坚戈',
'plural': '坚戈'
},
'Tugrik': {
'normal': '图格里克',
'plural': '图格里克'
},
'Vatu': {
'normal': '瓦图',
'plural': '瓦图'
},
'Won': {
'normal': '元',
'plural': '元'
},
'Yen': {
'normal': '元',
'plural': '元'
},
'Yuan': {
'normal': '元',
'plural': '元'
},
'ZiG': {
'normal': '津巴布韦金',
'plural': '津巴布韦金'
},
'Zloty': {
'normal': '兹罗提',
'plural': '兹罗提'
}
}
},
'category': {
'Food & Drink': '食品饮料',
'Food': '食品',
@@ -1131,6 +1471,7 @@ export default {
'Auto-update Exchange Rates Data': '自动更新汇率数据',
'Currency Display Mode': '货币显示模式',
'Currency Code': '货币代码',
'Currency Unit': '货币单位',
'Currency Name': '货币名称',
'Currency Symbol': '货币符号',
'Expense Amount Color': '支出金额颜色',