Default language is ignored for anyone who chose a language, when the language selector is hidden
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, internationalization
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
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.
- Dominant language
- PHP
- Stars
- 6.8k
- Forks
- 891
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 209
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from flarum/framework
-
type/accessibility type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
[2.x] False CLI/Web PHP mismatch when /usr/bin/php differs from the site's FPMPossibly taken @lazerg claimed this 15 days ago. Opentype/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[2.x] A filter on a resource without a searcher returns a 500Possibly taken @imorland claimed this today. Opentype/bug
flarum/framework#5578 · 1 assignee ·
Maintainers usually reply within 1 day
-
[2.x] Audit's discussion and user filters fail on PostgreSQLPossibly taken @imorland claimed this today. Opentype/bug
flarum/framework#5577 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in flarum/framework
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 87/100
Sylius/Sylius#19359 · 1 comment ·
Maintainers usually reply within 1 day
-
Add php 8.6Open
Difficulty 1/5 Under an hour Newbie friendliness 66/100
mailersend/mailersend-php#199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Configuration new tool
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
novalo-dev/Prestashop-MCP-Server#366 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 10 days