当前实现有两层语言包来源:
classpath:/i18n/<locale>/
也就是仓库里的:
src/main/resources/i18n/<locale>/
这一层是项目自带的默认语言包,保证系统开箱可用。
./stock/out/wcs/i18n/<locale>/
这一层是运行时可安装、可替换、可覆盖的语言包目录,对应 application.yml 里的 app.i18n.pack-path。
实际加载顺序:
当前已配置语言:
zh-CNen-US外置目录示例:
stock/out/wcs/i18n/
en-US/
messages.properties
legacy.properties
zh-CN/
messages.properties
legacy.properties
messages.properties用于稳定的 key 形式国际化。
适合以下内容:
legacy.properties用于旧页面的纯文本兼容替换。
这个项目里老的 Layui/jQuery 页面很多,存在大量直接写死的中文;这层是过渡方案,便于先让英文可用,再逐步把旧页面改成 key 化。
后端菜单翻译 key 由 sys_resource.code 推导。
例如:
resource.develop=Development
resource.ai.llm_config=AI Configuration
resource.notifyReport.notifyReport=Notification Report
resource.ai.llm_config.view=View
权限翻译 key 由 action 推导。
例如:
permission.function=Specified Functions
permission.user.resetPassword=Reset Password
例如:
common.profile=Profile
common.logout=Log Out
index.homeTab=Control Center
login.title=WCS System V3.0
如果只是使用项目自带中文和英文,不需要额外操作。
如果要安装外置语言包,按下面做:
stock/out/wcs/i18n/ 下创建新语言目录。messages.properties 和 legacy.properties 作为模板。系统会按配置周期检查外置目录,因此简单文本调整理论上不必重启;但正式环境建议仍按发布流程重启或重载。
messages.properties。legacy.properties 兼容,不要一开始就全量重构。zh-CNX-Langresource.code 自动生成可读名称,再回退到原始中文名