Default language is ignored for anyone who chose a language, when the language selector is hidden
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 77/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
从 Flarum\Http\Middleware\SetLocale 开始,issue 将其指出为该行为的来源,并追踪它如何读取选择器设置以及如何选择 locale。检查 middleware 测试是否覆盖已登录用户和访客。完成标准是:选择器隐藏时应用已配置的默认值,显示时已保存的语言选择仍然有效。
由索引模型根据 Issue 内容生成。
描述
Reported on discuss: https://discuss.flarum.org/d/40146
What happens
With Show language selector switched off, changing the forum's Default language in Basics has no effect for anyone who chose a language before, even after php flarum cache:clear. They keep seeing their earlier choice, and with the selector hidden they have no way to change it.
Steps to reproduce
- Install a second language pack (for example French) next to English.
- With the language selector shown, pick English from the selector.
- In Basics, switch Show language selector off and set Default language to French.
- Reload the forum: it is still in English.
The same happens to a guest who picked a language (via the locale cookie).
Cause
Flarum\Http\Middleware\SetLocale always applies the signed-in user's locale preference, or a guest's locale cookie, and never checks whether the language selector is shown:
if ($actor->exists) {
$locale = $actor->getPreference('locale');
} else {
$locale = Arr::get($request->getCookieParams(), 'locale');
}
Expected
When the selector is hidden, people can't choose a language, so the forum's default language should apply to everyone and saved choices should be ignored (but kept, so they come back if the selector is switched on again).
Seen on 2.0.2; the code is the same on 2.x.
- 主要语言
- PHP
- 星标
- 6.8k
- 派生
- 891
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 209
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
flarum/framework 的其他 Issue
-
type/accessibility type/bug
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
[2.x] False CLI/Web PHP mismatch when /usr/bin/php differs from the site's FPM可能已有人在做 @lazerg 于 15 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[2.x] A filter on a resource without a searcher returns a 500可能已有人在做 @imorland 今天认领。 未关闭type/bug
flarum/framework#5578 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[2.x] Audit's discussion and user filters fail on PostgreSQL可能已有人在做 @imorland 今天认领。 未关闭type/bug
flarum/framework#5577 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 87/100
维护者通常 1 天内回复
-
Add php 8.6未关闭
难度 1/5 1 小时以内 新手友好度 66/100
mailersend/mailersend-php#199 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
Configuration new tool
难度 2/5 1-3 小时 新手友好度 68/100
novalo-dev/Prestashop-MCP-Server#366 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 10 天内回复