Repository navigation
feat: 管理器和命令行的英文界面 - #192
Merged
Merged
Conversation
代码里照旧写中文,中文原文就是键:internal/i18n 按包放英文表,格式串和拼接按模式反向匹配。 只在给人看的地方翻:管理器的回答和事件、页面自己的字符串、托盘和消息框、命令行输出到控制台的人读输出。 --json、MCP、日志、问题包、mas-avd.json 不变。语言按 MODAVD_LANG、设置里选的、系统界面语言依次决定, 设置页可以切换。TestCatalog 查漏翻、过期、参数对不上和页面里写在 t() 外面的中文。 Refs ModAVD/ModAVD#165
页面模块在 node 测试里没有 document / fetch / location:i18n.js 只在页面里读语言表;data: URL 和 vm 加载的测试改成导入真的 i18n.js。更新确认框里的实例名照旧连在一起写。 Refs ModAVD/ModAVD#165
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
管理器和命令行有了英文界面(Refs ModAVD/ModAVD#165)。
MODAVD_LANG环境变量 → 设置里选的(存在%LOCALAPPDATA%\ModAVD\language.json)→ 系统界面语言。Windows 用GetUserDefaultUILanguage,zh-*是中文,其他一律英文;macOS / Linux 看LANG等和AppleLanguages。设置页里可以选「跟随系统 / 中文 / English」,改了立即生效,页面重新加载。language.json。这个用户的%LOCALAPPDATA%\ModAVD里已经有旧版写的东西(管理器窗口状态ui-*、update-settings.json、开机时的affinity.lock等)就算升级,定成中文;目录是空的才是新装,定成跟随系统。升级的人界面不会突然变成英文,想要英文去设置里改。internal/i18n。代码里照旧写中文,中文原文就是键,locales/en/<包>.json按包分(web.json是页面自己的字符串)。格式串(实例 %d 正在关机)和拼接("实例 " + name + " 已存在"→实例 %v 已存在)按模式反向匹配,参数再各自翻;整句没有键的,按「:」「;」「。」、括号、行、词拆开翻。加别的语言就是加一个locales/<代码>/目录。message、advice、warnings、检查项的title/reason等,见i18n/json.go),页面自己的字符串走t();托盘菜单、消息框、会话通知。--json时,输出到控制台的 stdout / stderr(结果先按字段翻,再排版,表格列宽按译文算)。--json的输出(信封里的message照旧是中文)、MCP、adb、shell的输出、退出码、错误码、mas-avd.json和实例文件、日志文件、问题包。输出重定向到文件或管道时(比如管理器自动更新写的logs\modavd-update.log)也不翻,除非设了MODAVD_LANG。中文时管理器的回答不重新编码,和原来逐字节相同。--json,读的是信封,不受影响。update.js里写死的zh-CN时间格式改成跟着语言走。TestCatalog查表:源码和页面里每条中文都有译文(或null表示故意不翻,比如问题包正文)、没有过期的键、译文参数和原文对得上、同一个键各包里译法一致、页面没有写在t()外面的中文。改了中文字符串以后go test ./internal/i18n -run TestCatalog -update把缺的键加进表,见internal/i18n/README.md。测试
go test ./...通过。MODAVD_LANG=en下跑help、各命令的help、check、list、info、status(缺参数报错),输出是英文;同样的命令带--json输出和原来一样是中文信封。没做 / 以后