- الحالة
- محلولة
- أُبلغ عنها لـ
- WPML String Translation 3.2.15
- تم حلها في
- 3.2.16
- وسوم الموضوع
- Bug
نظرة عامة على المشكلة
تنشأ هذه المشكلة عندما تفشل الترجمات المخصصة المخزنة في ملفات .mo في التحميل بشكل صحيح على WordPress 6.7.x أو أحدث. ترتبط المشكلة بتغييرات في كيفية تعامل WordPress مع تحميل الترجمة الفوري (JIT)، مما يتسبب في إلغاء تعيين إدخالات الترجمة في المتغير العام $l10n.
حل بديل مؤقت
يُرجى التأكد من أخذ نسخة احتياطية كاملة لموقعك قبل المتابعة.
- افتح الملف …/wp-content/plugins/wpml-string-translation/classes/MO/Hooks/LoadTextDomain.php.
- ابحث عن السطر 62.
- استبدل:
public function overrideLoadTextDomain( $override, $domain, $mofile ) { if ( ! $mofile ) { return $override; } if ( ! $this->isCustomMOLoaded( $domain ) ) { remove_filter( 'override_load_textdomain', [ $this, 'overrideLoadTextDomain' ], 10 ); $locale = $this->file_locale->get( $mofile, $domain ); $this->loadCustomMOFile( $domain, $mofile, $locale ); add_filter( 'override_load_textdomain', [ $this, 'overrideLoadTextDomain' ], 10, 3 ); } $this->loaded_mo_dictionary->addFile( $domain, $mofile ); return $override; } - بـ:
public function overrideLoadTextDomain( $override, $domain, $mofile ) { if ( ! $mofile ) { return $override; } if ( ! $this->isCustomMOLoaded( $domain ) ) { $locale = $this->file_locale->get( $mofile, $domain ); $wpml_mofile = $this->file_manager->get( $domain, $locale ); if ( ! file_exists( $mofile ) && $wpml_mofile ) { add_filter( 'load_translation_file', function($file) use ( $mofile, $wpml_mofile ) { if ( $file === $mofile ) { return $wpml_mofile; } return $file; // unset this own hook, just to be used once. }); return $override; } remove_filter( 'override_load_textdomain', [ $this, 'overrideLoadTextDomain' ], 10 ); $this->loadCustomMOFile( $domain, $mofile, $locale ); add_filter( 'override_load_textdomain', [ $this, 'overrideLoadTextDomain' ], 10, 3 ); } $this->loaded_mo_dictionary->addFile( $domain, $mofile ); return $override; }