create: FLUID 界面翻译使用外置 JSON 语言包

MemRelay-Operation: memory-save:uiframe-fluid-json-locale-20261122
MemRelay-Resource: fc5bc4b3-dfe5-41a8-bf3e-9b204a1847d7
This commit is contained in:
2026-11-22 03:57:53 +08:00
parent 94f39a97bb
commit 49584f79d2
@@ -0,0 +1,21 @@
---
title: FLUID 界面翻译使用外置 JSON 语言包
type: decision
permalink: main/projects/0017cd22-9dea-4f87-9595-fc050356ff3c/fluid-界面翻译使用外置-json-语言包
stable_id: fc5bc4b3-dfe5-41a8-bf3e-9b204a1847d7
scope: project
memory_type: decision
project_id: 0017cd22-9dea-4f87-9595-fc050356ff3c
usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998
status: active
revision: 1
request_id: uiframe-fluid-json-locale-20261122
created_at: '2026-11-21T19:57:49.684886+00:00'
updated_at: '2026-11-21T19:57:49.684886+00:00'
tags:
- fltk-plus
- fluid
- i18n
---
FLUID 自己的菜单和设置窗口不再把译文写进 C++ 表。英文是内置原文,不做语言包。其他语言放在 fltk-plus/fluid/locale/下的 UTF-8 JSON:字段 id、name、translations。键必须是界面上的英文原文,包括 & 快捷键标记。缺的键保持英文。文件名任意,以 .json 结尾。下拉框显示 name,偏好保存 id(ui_language_id)。旧的整数键 ui_language=1 仍当作简体中文。查找顺序:环境变量 FLUID_LOCALE_DIR,可执行文件旁边的 locale,再是 ../share/fltk-plus/locale。Windows 用 GetModuleFileNameW,macOS 用 _NSGetExecutablePath,Linux 用 /proc/self/exe。文件用 fl_fopen 读,以便中文路径在三个系统上都能打开。构建后把 locale 复制到 fluid.exe 旁边;安装时放到 ${FLTK_DATADIR}/fltk-plus/locale。中文字体按系统已装字体探测,不写死微软雅黑。测试必须跑 E:\code\UIFrame\fltk-plus\build\bin\fluid.exe,不要用 cargo 安装的旧 fluid。这次改动尚未提交、未推送。