Skip to content

Rely on just-in-time translation loading#608

Merged
kasparsd merged 2 commits intoWordPress:masterfrom
swissspidy:fix/load-textdomain
Apr 30, 2024
Merged

Rely on just-in-time translation loading#608
kasparsd merged 2 commits intoWordPress:masterfrom
swissspidy:fix/load-textdomain

Conversation

@swissspidy
Copy link
Copy Markdown
Member

What?

Removes the manual load_plugin_textdomain() call to rely on WordPress to load translations at the right time.

Bumps the requirement to WordPress 4.6 accordingly.

Also, defines the Requires * headers in the main plugin file so that WordPress can actually read them and prevent you from installing the plugin if requirements are not met.

The headers mustn't really be set in the readme.

Why?

The plugin was loading translations too early on plugins_loaded. Plugins should wait until init to ensure the current user has been set up, so that the current user's locale can be respected.

That said, why manually load translations when WordPress can do it for you :-)

How?

Testing Instructions

Switch to a different language and see that the translations are still loaded as expected.

Screenshots or screencast

Changelog Entry

Fixed - Ensured translations are only loaded just-in-time.

Copy link
Copy Markdown
Collaborator

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you so much!

@kasparsd kasparsd merged commit 66faeef into WordPress:master Apr 30, 2024
@swissspidy swissspidy deleted the fix/load-textdomain branch April 30, 2024 14:53
@jeffpaul jeffpaul added this to the 0.10.0 milestone May 8, 2024
@kasparsd kasparsd mentioned this pull request Sep 18, 2024
@jeffpaul jeffpaul modified the milestones: 0.11.0, 0.10.0 Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants