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

Aperta Adatta ai principianti
#5,409 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@1AbdullahButt ci sta già lavorando.

Dal 7/11/2026.

  • #5419 di @1AbdullahButt — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
laravel, php

Direzione di ricerca

Inizia da Flarum\Http\Middleware\SetLocale, che l’issue indica come origine del comportamento, e segui il modo in cui legge l’impostazione del selettore e sceglie una locale. Controlla nei test del middleware la copertura degli utenti autenticati e degli ospiti. Il lavoro è completo quando viene applicato il valore predefinito configurato mentre il selettore è nascosto e le scelte di lingua salvate continuano a funzionare quando viene mostrato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
6.8k
Fork
891
Merge medio
1g 10h
PR unite (30g)
209

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flarum/framework

Tutte le issue di flarum/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.