- Estado
- Resuelto
- Notificado para
- WPML String Translation 3.2.15
- Resuelto en
- 3.2.16
- Etiquetas de temática
- Bug
Resumen del problema
Este problema surge cuando las traducciones personalizadas almacenadas en archivos .mo no se cargan correctamente en WordPress 6.7.x o posterior. El problema está relacionado con cambios en cómo WordPress maneja la carga de traducciones Just-In-Time (JIT), lo que provoca que las entradas de traducción se eliminen de la variable global $l10n.
Solución alternativa
Por favor, asegúrese de tener una copia de seguridad completa de su sitio antes de continuar.
- Abra el archivo …/wp-content/plugins/wpml-string-translation/classes/MO/Hooks/LoadTextDomain.php.
- Busque la línea 62.
- Reemplace:
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; } - Por:
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; }