feedback6: the i18n template test reads the app range from APP_VERSION like tools/i18n.mjs appRange (it hard-coded >=0.2.0; 0.2.1-dev writes >=0.2.1)

This commit is contained in:
sganggs committed 2026-10-07 16:51:35 +08:00
1 parent ee43fb7c14
commit ac6de8a12d
1 file changed
+2 -1
+2 -1
View File
@@ -16,6 +16,7 @@ import path from 'node:path';
import { spawnSync } from 'node:child_process';
import http from 'node:http';
import { fileURLToPath } from 'node:url';
import { APP_VERSION } from '../shared/constants.js';
import {
t, tc, tParts, setLang, getLang, addMessages, setMessages, setI18nWarn, registerLangs, getLangs, langChain, langInfo, normalizeLang,
checkTranslation, parsePluralForms, pluralCategory, format,
@@ -417,7 +418,7 @@ test('tools: template writes a skeleton (or adds the missing msgids to a pack),
const used = new Map([['开始', { where: 'a.js:1', params: [] }], ['还剩 {n} 秒', { where: 'b.js:2', params: new Set(['n']) }], ['{n} 名', { where: 'c.js:3', params: new Set(['n', 'count']) }], ['表里的', { where: 'd.js:4', params: null }]]);
const skel = packTemplate('qaa', { msgids: [...used.keys()] });
assert.deepEqual(Object.keys(skel.json), ['_meta', '开始', '还剩 {n} 秒', '{n} 名', '表里的']);
assert.deepEqual([skel.json._meta.type, skel.json._meta.lang, skel.json._meta.fallback, skel.json._meta.app], ['lang', 'qaa', ['en'], '>=0.2.0']);
assert.deepEqual([skel.json._meta.type, skel.json._meta.lang, skel.json._meta.fallback, skel.json._meta.app], ['lang', 'qaa', ['en'], `>=${APP_VERSION.replace(/-.*$/, '')}`], 'this release and later (tools/i18n.mjs appRange)');
assert.equal(packTemplate('zh-TW', { msgids: [] }).json._meta.fallback.length, 0, 'a Chinese variant falls back to the Chinese msgid');
assert.equal(skel.json['开始'], '');
const again = packTemplate('qaa', { existing: { _meta: { name: 'Mine' }, 开始: 'Los', 旧的: 'alt' }, msgids: [...used.keys()], fill: { 还剩: 'x' } });