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

Open Beginner friendly
#5,409 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@1AbdullahButt is already working on this.

Since Nov 7, 2026.

  • #5419 by @1AbdullahButt — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
77/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
laravel, php

Research direction

Start with Flarum\Http\Middleware\SetLocale, which the issue names as the source of the behavior, and trace how it reads the selector setting and chooses a locale. Check the middleware tests for coverage of signed-in users and guests. Done means the configured default applies while the selector is hidden, and saved language choices still work when it is shown.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
6.8k
Forks
891
Avg merge
1d 10h
Merged PRs (30d)
209

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flarum/framework

All issues in flarum/framework

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.