Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
When listing available languages for a plugin using the wp language plugin list <plugin>
command, the status is always uninstalled
if 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 the list
command:
language-command/src/Plugin_Language_Command.php
Lines 92 to 153 in 24f76e3
That's where the following check (against an empty $installed_translations
array returned by get_installed_languages()
) results in the uninstalled
value:
A solution is to account for the discrepancy between plugin slugs and text domains in the get_installed_languages()
method.