Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-1208: Improve i18n support for WordPress 6.7 #1209

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

renatonascalves
Copy link

@renatonascalves renatonascalves commented Dec 7, 2024

fixes #1208

@renatonascalves renatonascalves marked this pull request as ready for review December 7, 2024 15:55
@renatonascalves renatonascalves changed the title issue-1208: WIP load-textdomain-error-wordpress-6-7 issue-1208: Improve i18n support for WordPress 6.7 Dec 7, 2024
Comment on lines -82 to -91
/**
* Load plugin textdomain.
*
* @since 0.9.0
*/
function apple_news_load_textdomain() {
load_plugin_textdomain( 'apple-news', false, __DIR__ . '/lang' );
}
add_action( 'plugins_loaded', 'apple_news_load_textdomain' );

Copy link
Author

@renatonascalves renatonascalves Dec 7, 2024

Choose a reason for hiding this comment

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

Since WordPress 4.7, this is no longer required for plugins hosted in WordPress.org.

The translation comes automatically from here: https://translate.wordpress.org/projects/wp-plugins/publish-to-apple-news/

*/
function apple_news_get_plugin_data() {
function apple_news_get_plugin_data( $translate = true ) {
Copy link
Author

Choose a reason for hiding this comment

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

Allow this function to be used before init, where translation is not supported or necessary. See the related changed unit test as part of this pr.

add_action(
'plugins_loaded',
[ $this, 'action_plugins_loaded' ]
'init',
Copy link
Author

@renatonascalves renatonascalves Dec 7, 2024

Choose a reason for hiding this comment

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

I learned as part of this fix that loading __( translations before init has always been incorrect from plugin developers. The difference now is that WordPress is making that obvious to developers like me as part of WordPress 6.7 and encouraging us to hook translation code in the proper hook.

Copy link

@mogmarsh mogmarsh left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_load_textdomain_just_in_time error with WordPress 6.7
2 participants