feat(rest,spec): 导出文件名本地化 + 系统字段标签内置多语言回退#2911
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📓 Docs Drift CheckThis PR changes 3 package(s): 97 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
真机 UI 复测报告(第二轮:「下载模板结果中还是有英文」)环境:objectstack dev :3000(showcase, 1. 导入模板 — 全中文 ✅UI 路径:任务 → In Progress 视图 → 导入 → 下载模板。实际下载:
所有者,标题 *,项目 *,负责人,状态 *,优先级,预计工时,进度,已完成,截止日期,开始日期,结束日期,创建时间,工作地点,封面,标签,备注,同步状态,同步错误
,,,,待规划,低,0,,true,2024-01-31,2024-01-31,2024-01-31,2024-01-31 09:00,,,,,已同步,第一轮遗留的英文( 2. 导出 — 文件名 + 单元格全中文 ✅UI 路径:同视图 → 导出 → 导出为 CSV。实际下载:
标题,项目,负责人,状态,优先级,截止日期
Build homepage,Website Relaunch,sam@example.com,进行中,高,2026-07-24
Ingest pipeline,Data Platform,linus@example.com,进行中,紧急,2026-08-033. 导出↔导入闭环(本次新发现并修复的平台缺陷)✅导出/模板写出的是翻译后的选项标签,但导入 coercion 只认作者原始标签 → 把自己导出的中文文件导回去,select 字段全报 实测(dry-run POST
4. 测试
操作截图(导入对话框、In Progress 网格中文状态列)已在开发会话中留存。 |
…abel fallback - rest: GET /data/:object/export Content-Disposition now uses the object's display label + timestamp via RFC 5987/6266 (ASCII api-name fallback in filename=, localized label in filename*=UTF-8''). New exportContentDisposition(). - spec: translateObject gains built-in en/zh-CN/ja-JP/es-ES labels for the five registry-injected system fields (owner_id/created_at/created_by/ updated_at/updated_by), applied only when the label is still the injected English default; works without a translation bundle. REST meta translation no longer bails out when the bundle is missing (ETag is already locale-keyed). - plugin-reports: attachment filename sanitizer keeps Unicode letters/digits instead of flattening CJK to underscores. - showcase: enable exportOptions on the task In Progress view so export is demonstrated (and UI-testable) in the example app.
…mport round-trip) The localized export and the import template surface translated option labels (e.g. 待规划 for backlog), but import coercion only knew the authored schema labels — re-importing your own localized export failed every select field with invalid_option. - prepareImportRequest gains a localizeSchema hook; both REST import routes pass translateMetaItem so the request locale's labels merge into the field metaMap as matching synonyms (authored labels and option codes keep working; unknown values still fail; a throwing hook degrades to authored-only matching) - new mergeLocalizedOptionSynonyms export + import-prepare tests - app-showcase: complete the showcase_task en/zh-CN translation bundle (done/labels/sync_status/sync_error labels, status/priority/sync option maps) so templates and exports render fully localized
背景
用户反馈两处问题:
contracts.csv这种裸 API 名,希望优化为「对象显示名-时间戳」。prepare)。前端配套 PR:objectui(导出文件名前端兜底、导入模板示例值取显示标签、模板文件名本地化)。
变更
@objectstack/rest— 导出下载文件名GET /data/:object/export的Content-Disposition改为「对象显示名-时间戳」,按 RFC 5987/6266 双写:filename="task-20260714-153045.xlsx"(ASCII 兜底)+filename*=UTF-8''任务-20260714-153045.xlsx(本地化标签)。exportContentDisposition(objectName, label, ext, now?)。@objectstack/spec— 系统字段标签内置回退owner_id/created_at/created_by/updated_at/updated_by)只有英文标签,自定义对象没有对应翻译条目,导致中文界面漏出 "Owner"/"Created At"。translateObject内置这五个字段的 en/zh-CN/ja-JP/es-ES 标签表(措辞与平台翻译包一致),仅当字段标签仍是注入的英文默认值时套用,作者自定义标签绝不覆盖;无翻译包时也生效。@objectstack/plugin-reports— 附件文件名_」改为按 Unicode 字母/数字保留(\p{L}\p{N}),中文计划名不再变成下划线串。showcase
exportOptions: ['csv','xlsx','json'],示例应用可直接演示/实测导出。测试
exportContentDisposition5 例、系统字段回退 6 例)、plugin-reports 29 通过。curl -H 'Accept-Language: zh-CN' …/export?format=xlsx→content-disposition: attachment; filename="showcase_task-20260714-063010.xlsx"; filename*=UTF-8''%E4%BB%BB%E5%8A%A1-…(即任务-….xlsx);en-US →Task-….csv。任务-20260714-064550.csv、任务-20260714-064607.xlsx。created_at显示「创建时间」。追加(6ab3e7c):导出↔导入选项标签闭环
第二轮实测发现平台级缺陷:导出/模板写出的是翻译后的选项标签(如
待规划),但导入 coercion 只认作者原始标签——用户把自己刚导出的中文文件原样导回,select 字段全报invalid_option。prepareImportRequest新增localizeSchema钩子;REST 两处导入路由传translateMetaItem,把翻译标签并入选项匹配同义词(mergeLocalizedOptionSynonyms)。invalid_option;钩子抛错时静默降级为原 schema。showcase_tasken/zh-CN 翻译包(status/priority/done/labels/sync_status/sync_error),消除模板残留英文。import-prepare.test.ts);真机 dry-run:中文标签导回ok:1、英文标签不回归、非法值仍拦截(详见 PR 评论实测报告)。Closes #2916