mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Merge pull request #1752 from RooVetGit/i18n_format
Localize formatting helpers
This commit is contained in:
commit
56ff9ea77b
16 changed files with 127 additions and 29 deletions
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "mil",
|
||||
"million_suffix": "M",
|
||||
"billion_suffix": "MM"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "Tsd.",
|
||||
"million_suffix": "Mio.",
|
||||
"billion_suffix": "Mrd."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "k",
|
||||
"million_suffix": "m",
|
||||
"billion_suffix": "b"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "k",
|
||||
"million_suffix": "M",
|
||||
"billion_suffix": "MM"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "k",
|
||||
"million_suffix": "M",
|
||||
"billion_suffix": "Md"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "ह",
|
||||
"million_suffix": "लाख",
|
||||
"billion_suffix": "अरब"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "k",
|
||||
"million_suffix": "Mln",
|
||||
"billion_suffix": "Mld"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "k",
|
||||
"million_suffix": "M",
|
||||
"billion_suffix": "B"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "천",
|
||||
"million_suffix": "백만",
|
||||
"billion_suffix": "십억"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "tys.",
|
||||
"million_suffix": "mln",
|
||||
"billion_suffix": "mld"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "mil",
|
||||
"million_suffix": "mi",
|
||||
"billion_suffix": "bi"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "B",
|
||||
"million_suffix": "Mn",
|
||||
"billion_suffix": "Mr"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "k",
|
||||
"million_suffix": "tr",
|
||||
"billion_suffix": "tỷ"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "千",
|
||||
"million_suffix": "百万",
|
||||
"billion_suffix": "十亿"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
{}
|
||||
{
|
||||
"number_format": {
|
||||
"thousand_suffix": "千",
|
||||
"million_suffix": "百萬",
|
||||
"billion_suffix": "十億"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,35 @@
|
|||
import i18next from "i18next"
|
||||
|
||||
export function formatLargeNumber(num: number): string {
|
||||
if (num >= 1e9) {
|
||||
return (num / 1e9).toFixed(1) + "b"
|
||||
return (num / 1e9).toFixed(1) + i18next.t("common:number_format.billion_suffix")
|
||||
}
|
||||
if (num >= 1e6) {
|
||||
return (num / 1e6).toFixed(1) + "m"
|
||||
return (num / 1e6).toFixed(1) + i18next.t("common:number_format.million_suffix")
|
||||
}
|
||||
if (num >= 1e3) {
|
||||
return (num / 1e3).toFixed(1) + "k"
|
||||
return (num / 1e3).toFixed(1) + i18next.t("common:number_format.thousand_suffix")
|
||||
}
|
||||
return num.toString()
|
||||
}
|
||||
|
||||
export const formatDate = (timestamp: number) => {
|
||||
const date = new Date(timestamp)
|
||||
return date
|
||||
.toLocaleString("en-US", {
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
hour12: true,
|
||||
})
|
||||
.replace(", ", " ")
|
||||
.replace(" at", ",")
|
||||
.toUpperCase()
|
||||
const locale = i18next.language || "en"
|
||||
|
||||
// Get date format style from translations or use default transformations
|
||||
const dateStr = date.toLocaleString(locale, {
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
hour12: true,
|
||||
})
|
||||
|
||||
// Apply transformations based on locale or use default
|
||||
if (locale === "en") {
|
||||
return dateStr.replace(", ", " ").replace(" at", ",").toUpperCase()
|
||||
}
|
||||
|
||||
return dateStr.toUpperCase()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue