WordPress / health-check

Health Check is a WordPress plugin that will perform a number of checks on your WordPress install to detect common configuration errors and known issues.
GNU General Public License v2.0
175 stars 56 forks source link

Wrong Language on swedish site language and english user profile language #448

Closed ipajen closed 1 year ago

ipajen commented 1 year ago

Feature request/bug description

WordPress: 6.2 PHP: 8.2.3 Server: LiteSpeed Database: mysqli (Server: 10.4.28-MariaDB / Client: mysqlnd 8.2.3) Browser: Edge 111.0.1661.62 (Windows 10/11) Theme: GeneratePress 3.3.0 Health Check & Troubleshooting 1.6.0

Got a issue with languages in Health check

Site Language = English US and User Profile Language = English Status, Info, Troubleshooting, Tools

Site Language = English US and User Profile Language = Swedish Status, Info, Felsökning, Verktyg

Site Language = Swedish and User Profile Language = English US Status, Info, Felsökning, Verktyg

Site Language = Swedish and User Profile Language = Swedish Status, Info, Felsökning, Verktyg

When site language are Swedish and User Profile Language are English US the wrong language is shown in the Troubleshooting, Tools?

Site Language = English US and User Profile Language = Swedish The headers are translated but not the text. See pictures

Site Language = Swedish and User Profile Language = Swedish The headers are translated and text. See pictures

Screenshots

Is this a visual related ticket? If so, please include one or more screenshots to help us better understand what is happening.

Sitelanguage_US_and_Userlanguage_SE Sitelanguage_SE_and_Userlanguage_SE

ipajen commented 1 year ago

IMG_4296 Added picture where translation is showing up incorrectly under plugins - troubleshooting

Zodiac1978 commented 1 year ago

Maybe @swissspidy can help here?

swissspidy commented 1 year ago

From what I can see at a glance is that the way the code is loaded in the plugin causes the just-in-time translation logic in WP to trigger before the current user locale is known.

This is because the main plugin file loads a bunch of classes which get immediately instantiated before plugins_loaded, and these classes call __():

https://github.com/WordPress/health-check/blob/1e0b6f51d2cada60fbc58c10db94d1688af2bb8c/health-check.php#L66-L73

https://github.com/WordPress/health-check/blob/1e0b6f51d2cada60fbc58c10db94d1688af2bb8c/HealthCheck/Tools/class-health-check-files-integrity.php#L20-L21

https://github.com/WordPress/health-check/blob/1e0b6f51d2cada60fbc58c10db94d1688af2bb8c/HealthCheck/Tools/class-health-check-files-integrity.php#L297

Doing all the main plugin initialization only on plugins_loaded would solve this.


See also https://core.trac.wordpress.org/ticket/58546