WPML
סטטוס
נפתר
דווח עבור
WPML String Translation 3.2.15
נפתר בגרסה
3.2.16
תגיות נושא
Bug

סקירה כללית של התקלה

בעיה זו מתרחשת כאשר תרגומים מותאמים אישית המאוחסנים בקובצי .mo אינם נטענים כראוי ב־WordPress 6.7.x ומעלה. הבעיה קשורה לשינויים באופן שבו WordPress מטפל בטעינת תרגומים מסוג Just-In-Time (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;
    	}

כל התקלות הידועות →