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

オープン 初心者向け
#5,409 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@1AbdullahButt がすでに取り組んでいます。

2026年11月7日 から。

  • #5419 @1AbdullahButt による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
77/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
laravel, php

調査の方向性

動作の原因としてissueで挙げられている Flarum\Http\Middleware\SetLocale から始め、セレクター設定の読み取り方と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時間
マージ済み PR(30日)
209

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

flarum/framework のほかの issue

flarum/framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。