Default language is ignored for anyone who chose a language, when the language selector is hidden

未关闭 适合新手
#5,409 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@1AbdullahButt 已经在做这个了。

开始于 2026年11月7日。

  • #5419 来自 @1AbdullahButt —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
laravel, php

调研方向

从 Flarum\Http\Middleware\SetLocale 开始,issue 将其指出为该行为的来源,并追踪它如何读取选择器设置以及如何选择 locale。检查 middleware 测试是否覆盖已登录用户和访客。完成标准是:选择器隐藏时应用已配置的默认值,显示时已保存的语言选择仍然有效。

由索引模型根据 Issue 内容生成。

描述

type/bug

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
  1. Install a second language pack (for example French) next to English.
  2. With the language selector shown, pick English from the selector.
  3. In Basics, switch Show language selector off and set Default language to French.
  4. 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flarum/framework 的其他 Issue

查看 flarum/framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。