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

Đang mở Phù hợp với người mới
#5,409 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@1AbdullahButt đang làm issue này rồi.

Từ ngày 7/11/2026.

  • #5419 của @1AbdullahButt — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
laravel, php

Hướng nghiên cứu

Bắt đầu với Flarum\Http\Middleware\SetLocale, thành phần mà issue nêu là nguồn gây ra hành vi này, rồi theo dõi cách nó đọc cài đặt của bộ chọn và chọn locale. Kiểm tra các bài kiểm thử middleware để xem người dùng đã đăng nhập và khách đã được bao phủ chưa. Hoàn thành khi giá trị mặc định đã cấu hình được áp dụng lúc bộ chọn bị ẩn, và các lựa chọn ngôn ngữ đã lưu vẫn hoạt động khi bộ chọn được hiển thị.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
6.8k
Fork
891
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
209

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flarum/framework

Tất cả issue của flarum/framework

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.