mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-24 18:26:17 +03:00
feat(i18n): use compact number format instead K/M suffix (#678)
This commit is contained in:
parent
d0567c0d18
commit
ca93f1a813
11 changed files with 14 additions and 30 deletions
|
@ -8,18 +8,18 @@ export const formattedNumber = (num: number, useFormatter: Intl.NumberFormat = f
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useHumanReadableNumber = () => {
|
export const useHumanReadableNumber = () => {
|
||||||
const { t, n, locale } = useI18n()
|
const { n, locale } = useI18n()
|
||||||
|
|
||||||
const fn = (num: number) => {
|
const fn = (num: number) => {
|
||||||
if (num < 10000)
|
return n(
|
||||||
return n(num, 'smallCounting', locale.value)
|
num,
|
||||||
|
num < 10000
|
||||||
// show 1 decimal: we cannot use toFixed(1), it is a string
|
? 'smallCounting'
|
||||||
if (num < 1000000)
|
: num < 1000000
|
||||||
return `${n(Math.floor(num / 100) / 10, 'kiloCounting', locale.value)}${t('common.kiloSuffix')}`
|
? 'kiloCounting'
|
||||||
|
: 'millionCounting',
|
||||||
// show 2 decimals: we cannot use toFixed(2), it is a string
|
locale.value,
|
||||||
return `${n(Math.floor(num / 10000) / 100, 'millionCounting', locale.value)}${t('common.megaSuffix')}`
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -107,11 +107,13 @@ const numberFormats = Object.values(locales).reduce((acc, data) => {
|
||||||
maximumFractionDigits: 0,
|
maximumFractionDigits: 0,
|
||||||
},
|
},
|
||||||
kiloCounting: {
|
kiloCounting: {
|
||||||
style: 'decimal',
|
notation: 'compact',
|
||||||
|
compactDisplay: 'short',
|
||||||
maximumFractionDigits: 1,
|
maximumFractionDigits: 1,
|
||||||
},
|
},
|
||||||
millionCounting: {
|
millionCounting: {
|
||||||
style: 'decimal',
|
notation: 'compact',
|
||||||
|
compactDisplay: 'short',
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,6 @@
|
||||||
"end_of_list": "نهاية القائمة",
|
"end_of_list": "نهاية القائمة",
|
||||||
"error": "حدث خطأ",
|
"error": "حدث خطأ",
|
||||||
"in": "في",
|
"in": "في",
|
||||||
"kiloSuffix": "ألف",
|
|
||||||
"megaSuffix": "مليون",
|
|
||||||
"not_found": "404 غير معثور عليه",
|
"not_found": "404 غير معثور عليه",
|
||||||
"offline_desc": "يبدو أنك غير متصل بالإنترنت. يرجى التحقق من اتصالك."
|
"offline_desc": "يبدو أنك غير متصل بالإنترنت. يرجى التحقق من اتصالك."
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,8 +64,6 @@
|
||||||
"common": {
|
"common": {
|
||||||
"end_of_list": "Konec seznamu",
|
"end_of_list": "Konec seznamu",
|
||||||
"error": "CHYBA",
|
"error": "CHYBA",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "404 Nenalezeno!",
|
"not_found": "404 Nenalezeno!",
|
||||||
"offline_desc": "Zdá se, že jste offline. Zkontrolujte připojení k internetu."
|
"offline_desc": "Zdá se, že jste offline. Zkontrolujte připojení k internetu."
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,8 +64,6 @@
|
||||||
"common": {
|
"common": {
|
||||||
"end_of_list": "Ende der Liste",
|
"end_of_list": "Ende der Liste",
|
||||||
"error": "FEHLER",
|
"error": "FEHLER",
|
||||||
"kiloSuffix": "T",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "404 Nicht Gefunden",
|
"not_found": "404 Nicht Gefunden",
|
||||||
"offline_desc": "Anscheinend bist du offline. Bitte überprüfe deine Netzwerkverbindung."
|
"offline_desc": "Anscheinend bist du offline. Bitte überprüfe deine Netzwerkverbindung."
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,8 +85,6 @@
|
||||||
"end_of_list": "End of the list",
|
"end_of_list": "End of the list",
|
||||||
"error": "ERROR",
|
"error": "ERROR",
|
||||||
"in": "in",
|
"in": "in",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "404 Not Found",
|
"not_found": "404 Not Found",
|
||||||
"offline_desc": "Seems like you are offline. Please check your network connection."
|
"offline_desc": "Seems like you are offline. Please check your network connection."
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,8 +85,6 @@
|
||||||
"end_of_list": "End of the list",
|
"end_of_list": "End of the list",
|
||||||
"error": "ERROR",
|
"error": "ERROR",
|
||||||
"in": "in",
|
"in": "in",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "404 Not Found",
|
"not_found": "404 Not Found",
|
||||||
"offline_desc": "Seems like you are offline. Please check your network connection."
|
"offline_desc": "Seems like you are offline. Please check your network connection."
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,8 +83,6 @@
|
||||||
"end_of_list": "Fin",
|
"end_of_list": "Fin",
|
||||||
"error": "ERROR",
|
"error": "ERROR",
|
||||||
"in": "en",
|
"in": "en",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "404 No Encontrado",
|
"not_found": "404 No Encontrado",
|
||||||
"offline_desc": "Al parecer estás fuera de línea. Por favor, comprueba tu conexión a la red."
|
"offline_desc": "Al parecer estás fuera de línea. Por favor, comprueba tu conexión a la red."
|
||||||
},
|
},
|
||||||
|
|
|
@ -82,8 +82,6 @@
|
||||||
"end_of_list": "Fin de liste",
|
"end_of_list": "Fin de liste",
|
||||||
"error": "ERREUR",
|
"error": "ERREUR",
|
||||||
"in": "sur",
|
"in": "sur",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "404 Introuvable",
|
"not_found": "404 Introuvable",
|
||||||
"offline_desc": "Il semble que vous soyez hors-ligne. Vérifiez votre connexion internet."
|
"offline_desc": "Il semble que vous soyez hors-ligne. Vérifiez votre connexion internet."
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,8 +85,6 @@
|
||||||
"end_of_list": "列表到底啦",
|
"end_of_list": "列表到底啦",
|
||||||
"error": "错误",
|
"error": "错误",
|
||||||
"in": "在",
|
"in": "在",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "无法找到相关内容",
|
"not_found": "无法找到相关内容",
|
||||||
"offline_desc": "您目前已离线,请检查网络连接。"
|
"offline_desc": "您目前已离线,请检查网络连接。"
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,8 +85,6 @@
|
||||||
"end_of_list": "列表到底啦",
|
"end_of_list": "列表到底啦",
|
||||||
"error": "錯誤",
|
"error": "錯誤",
|
||||||
"in": "在",
|
"in": "在",
|
||||||
"kiloSuffix": "K",
|
|
||||||
"megaSuffix": "M",
|
|
||||||
"not_found": "無法找到相關內容",
|
"not_found": "無法找到相關內容",
|
||||||
"offline_desc": "您目前已離線,請檢查網絡連接。"
|
"offline_desc": "您目前已離線,請檢查網絡連接。"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue