-
Notifications
You must be signed in to change notification settings - Fork 25
Fix language status detection for plugins/themes with text domain different from slug #171
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
Open
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/fix-language-installation-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…n slug Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix incorrect language installation status for plugins
Fix language status detection for plugins/themes with text domain different from slug
Nov 8, 2025
Copilot finished work on behalf of
swissspidy
November 8, 2025 16:33
Member
|
@copilot you added a test for plugins, but can you add one for themes as well? |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Author
Copilot finished work on behalf of
swissspidy
November 10, 2025 15:58
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
wp language plugin listandwp language theme listincorrectly report all translations as "uninstalled" when a plugin or theme's directory slug differs from its text domain. This occurs becausewp_get_installed_translations()keys results by text domain, but the code was checking using the slug.Changes
CommandWithTranslation::get_installed_languages()to read theTextDomainheader from plugin data and theme metadata, using it instead of slug when checking installed translationsTextDomainis empty (preserves backward compatibility)Example
Before:
After:
Checklist
Original prompt
<issue_description>## Bug Report
Describe the current, buggy behavior
When listing available languages for a plugin using the
wp language plugin list <plugin>command, the status is alwaysuninstalledif the plugin's slug ≠ plugin's text domain.This is due to the wp_get_installed_translations() method used in
language-command/src/WP_CLI/CommandWithTranslation.php
Lines 251 to 257 in 24f76e3
wp_get_installed_translations()returns an array keyed by the text domain. As a result, the subsequent check for available languages ($available = ! empty( $available[ $slug ] ) ? array_keys( $available[ $slug ] ) : array();) results in an empty array if the plugin's slug is different from its text domain.get_installed_languages()is used by thelistcommand:language-command/src/Plugin_Language_Command.php
Lines 92 to 153 in 24f76e3
That's where the following check (against an empty
$installed_translationsarray returned byget_installed_languages()) results in theuninstalledvalue:language-command/src/Plugin_Language_Command.php
Line 125 in 24f76e3
A solution is to account for the discrepancy between plugin slugs and text domains in the
get_installed_languages()method.</issue_description>Comments on the Issue (you are @copilot in this section)
@swissspidy Can you give an example of a plugin where this is happening?How would WP-CLI know what the correct text domain would be for the plugin?
WordPress plugins are really meant to have matching slugs and text domains. If they don't match, this kind of situation is to be expected. I assume WordPress itself also doesn't recognize the translations as being installed in that case.</comment_new>
<comment_new>@swissspidy
> It does because it relies on the text domain, not the plugin slug.
For loading, yes, but for updates I don't think WP has any such logic. At least I can't find it.
Looking at the
Text Domainheader sounds like an interesting hardening step, but also a bit unusual because of that.</comment_new>Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.