From 1416266bcb9575219d8159ff8e0ad4fb74be9a59 Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Thu, 22 Oct 2026 22:07:09 +0400 Subject: [PATCH] fix(i18n): avoid duplicate Chinese FIRMS age suffix --- src/i18n/firms-live-zh.test.mjs | 43 +++++++++++++++++++++++++++++++++ src/i18n/locales/zh-CN.json | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/i18n/firms-live-zh.test.mjs diff --git a/src/i18n/firms-live-zh.test.mjs b/src/i18n/firms-live-zh.test.mjs new file mode 100644 index 000000000..649842e7f --- /dev/null +++ b/src/i18n/firms-live-zh.test.mjs @@ -0,0 +1,43 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { getLocale, setLocale } from './index.js'; +import { createModel } from '../layers/firms/model.js'; +import { createQueries } from '../layers/firms/queries.js'; + +const cases = [ + [0, '不到 1 分钟前', '<1m ago'], + [120000, '2 分钟前', '2m ago'], + [7200000, '2 小时前', '2h ago'], +]; + +for (const [age, zh, en] of cases) { + test(`FIRMS live age ${age} ms has one relative-time suffix`, (context) => { + const now = 1800000000000; + context.mock.method(Date, 'now', () => now); + const previousLocale = getLocale(); + const layerState = { + _loading: false, + _stale: false, + _keyRequired: false, + _error: null, + _lastUpdate: now - age, + _count: 1, + _cellCount: 0, + _fires: [], + }; + const model = createModel({ services: { anchors: {} } }); + const { methods } = createQueries({ + layerState, + components: { model }, + config: {}, + }); + try { + setLocale('en'); + assert.equal(methods.getStats().loadingLabel, `LIVE · updated ${en}`); + setLocale('zh-CN'); + assert.equal(methods.getStats().loadingLabel, `实时 · 更新于 ${zh}`); + } finally { + setLocale(previousLocale); + } + }); +} diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index aee065901..0816935f6 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -714,7 +714,7 @@ "refreshing...": "刷新中…", "loading...": "加载中…", "KEY REQUIRED": "需要密钥", - "LIVE · updated {age}": "实时 · 更新于 {age}前", + "LIVE · updated {age}": "实时 · 更新于 {age}", "Source snapshot time unavailable": "来源快照时间不可用", "Live data unavailable": "实时数据不可用", "Low-accuracy score < 2%": "低精度评分 < 2%",