[5.x]: Translations issue when disabling commerce plugin

Đang mở
#20,051 1 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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading how Craft configures Yii's translation categories and how the Utilities page loads messages when a plugin is disabled. The issue gives a reproduction and a custom module workaround, but does not name the relevant files or a test. Done means Utilities loads without the 'commerce' message source error when Commerce is disabled.

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

Mô tả

bug repo:cms
What happened?
Description

Hello,

I don't know if this is a Craft issue or a Commerce issue, but if you disable Commerce without uninstalling it, you are hit with a translations issue when browsing to Utilities.

Unable to locate message source for category 'commerce'.

Obviously commerce leaves behind commerce related translations that Craft is unable to resolve if the plugin is disabled. However, I was able to fix this, by adding some code into a custom module/plugin.

use yii\i18n\PhpMessageSource;
if (!Craft::$app->getPlugins()->isPluginEnabled('commerce')) {
      if (!isset(Craft::$app->getI18n()->translations['commerce'])) {
        Craft::$app->getI18n()->translations['commerce'] = [
          'class' => PhpMessageSource::class,
          'basePath' => '@app/translations', 
          'forceTranslation' => true,
        ];
      }
}

Should a base 'commerce' translation be initialised in base Craft to cover for this, if commerce is disabled?

Craft CMS version

Craft Pro 5.11.5.1

PHP version

8.5

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions
Ngôn ngữ chính
PHP
Star
3.6k
Fork
714
Merge trung bình
13 giờ 9 phút
Pull request đã merge (30 ngày)
378

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 craftcms/cms

Tất cả issue của craftcms/cms

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.