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

Don't manually load translation files #7713

Merged
merged 4 commits into from
Dec 2, 2024

Conversation

donnapep
Copy link
Collaborator

@donnapep donnapep commented Nov 28, 2024

Resolves failing unit tests with the following message:

PHP Notice:  Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>***-lms</code> domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the <code>init</code> action or later. Please see <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0.)

Also resolves failing e2e tests.

Proposed Changes

As per the docs, it's no longer necessary to manually load translation files. As all of Sensei's translation files now exist on translate.wordpress.org, I think we can get rid of the code to load translations.

Testing Instructions

  1. Disable all other plugins except Sensei.
  2. On trunk, set the site language to anything other than English.
  3. Download language packs if necessary.
  4. Ensure that Sensei is translated.
  5. Switch to this branch.
  6. Ensure that Sensei is still translated.
  7. Check that the above notice is not displayed in the logs (note that I wasn't able to get it to appear in the logs prior to this change).

Deprecated Code

  • load_localisation
  • load_plugin_textdomain

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • Code is tested on the minimum supported PHP and WordPress versions

@donnapep donnapep self-assigned this Nov 28, 2024
Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

@donnapep donnapep added this to the 4.24.5 milestone Nov 28, 2024
Copy link

Test the previous changes of this PR with WordPress Playground.

@donnapep donnapep changed the title No need to manually load translations anymore Don't manually load translation files Nov 28, 2024
@donnapep donnapep added the Deprecation This change introduces a deprecation. label Nov 28, 2024
Copy link

Test the previous changes of this PR with WordPress Playground.

@donnapep donnapep requested a review from a team November 28, 2024 15:44
Copy link
Member

@m1r0 m1r0 left a comment

Choose a reason for hiding this comment

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

Translations are working as before. 👍

@donnapep donnapep merged commit e6bf3b1 into trunk Dec 2, 2024
23 checks passed
@donnapep donnapep deleted the remove/loading-translations-code branch December 2, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecation This change introduces a deprecation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants