- 상태
- 해결됨
- 보고된 제품
- WPML String Translation 3.2.15
- 해결된 버전
- 3.2.16
- 주제 태그
- Bug
문제 개요
이 문제는 WordPress 6.7.x 이상에서 .mo 파일에 저장된 사용자 정의 번역이 올바르게 로드되지 않을 때 발생합니다. 이 문제는 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; }