diff --git a/design/prototype/serve.mjs b/design/prototype/serve.mjs index 811eaf4..3d3ad9c 100644 --- a/design/prototype/serve.mjs +++ b/design/prototype/serve.mjs @@ -47,6 +47,19 @@ const server = http.createServer((req, res) => { let urlPath = decodeURIComponent(req.url.split('?')[0]); if (urlPath === '/') urlPath = '/index.html'; + + // i18n 单源:直接服务 canonical design/i18n/strings.json(不在原型内复制)。 + // 原型与 Flutter app 共用同一份翻译数据(design/codegen/gen_l10n_dart.mjs 由它生成 Dart)。 + if (urlPath === '/i18n/strings.json' || urlPath === '/strings.json') { + const sjPath = path.join(ROOT, '..', 'i18n', 'strings.json'); + fs.readFile(sjPath, (err, data) => { + if (err) { res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' }); res.end('strings.json not found'); return; } + res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store' }); + res.end(data); + }); + return; + } + const filePath = path.join(ROOT, urlPath); if (!filePath.startsWith(ROOT)) { res.writeHead(403); res.end('forbidden'); return; }