fix(i18n): use English runtime text and localize system UI

This commit is contained in:
Arthur Koba
2026-10-25 19:44:15 +03:00
parent ada0550571
commit 65a96670d5
289 changed files with 8092 additions and 3426 deletions
+14 -7
View File
@@ -43,28 +43,35 @@ func Bytes2Size(num int64) string {
return numStr + " " + unit
}
// Seconds2Time converts a number of seconds to a human-readable Chinese duration string.
// Seconds2Time converts a number of seconds to a human-readable English duration string.
func Seconds2Time(num int) (time string) {
if num/secondsPerYear > 0 {
time += strconv.Itoa(num/secondsPerYear) + " 年 "
time += durationPart(num/secondsPerYear, "year") + " "
num %= secondsPerYear
}
if num/secondsPerMonth > 0 {
time += strconv.Itoa(num/secondsPerMonth) + " 个月 "
time += durationPart(num/secondsPerMonth, "month") + " "
num %= secondsPerMonth
}
if num/secondsPerDay > 0 {
time += strconv.Itoa(num/secondsPerDay) + " 天 "
time += durationPart(num/secondsPerDay, "day") + " "
num %= secondsPerDay
}
if num/secondsPerHour > 0 {
time += strconv.Itoa(num/secondsPerHour) + " 小时 "
time += durationPart(num/secondsPerHour, "hour") + " "
num %= secondsPerHour
}
if num/secondsPerMinute > 0 {
time += strconv.Itoa(num/secondsPerMinute) + " 分钟 "
time += durationPart(num/secondsPerMinute, "minute") + " "
num %= secondsPerMinute
}
time += strconv.Itoa(num) + " 秒"
time += durationPart(num, "second")
return
}
func durationPart(value int, unit string) string {
if value != 1 {
unit += "s"
}
return strconv.Itoa(value) + " " + unit
}
+6 -6
View File
@@ -35,12 +35,12 @@ func TestSeconds2Time(t *testing.T) {
input int
expected string
}{
{0, "0 秒"},
{30, "30 秒"},
{60, "1 分钟 0 秒"},
{125, "2 分钟 5 秒"},
{3600, "1 小时 0 秒"},
{86400, "1 天 0 秒"},
{0, "0 seconds"},
{30, "30 seconds"},
{60, "1 minute 0 seconds"},
{125, "2 minutes 5 seconds"},
{3600, "1 hour 0 seconds"},
{86400, "1 day 0 seconds"},
}
for _, tt := range tests {