From 1fcdbf7ecbeb87f861d0c486cc235a6b146eacd5 Mon Sep 17 00:00:00 2001 From: Erika Gili Date: Thu, 13 Jun 2024 10:43:08 +0200 Subject: [PATCH 1/5] Remove default available translation for plugins and themes --- src/WP_CLI/CommandWithTranslation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/WP_CLI/CommandWithTranslation.php b/src/WP_CLI/CommandWithTranslation.php index ca4b2b9e..2f27f37e 100644 --- a/src/WP_CLI/CommandWithTranslation.php +++ b/src/WP_CLI/CommandWithTranslation.php @@ -251,7 +251,6 @@ protected function download_language_pack( $download, $slug = null ) { protected function get_installed_languages( $slug = 'default' ) { $available = wp_get_installed_translations( $this->obj_type ); $available = ! empty( $available[ $slug ] ) ? array_keys( $available[ $slug ] ) : array(); - $available[] = 'en_US'; return $available; } From 73a5a52f80ced508bc0610b8a3fa1d8b72b8e4e9 Mon Sep 17 00:00:00 2001 From: Erika Gili Date: Thu, 13 Jun 2024 10:54:29 +0200 Subject: [PATCH 2/5] Fix phpcs issue --- src/WP_CLI/CommandWithTranslation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WP_CLI/CommandWithTranslation.php b/src/WP_CLI/CommandWithTranslation.php index 2f27f37e..c3e06e73 100644 --- a/src/WP_CLI/CommandWithTranslation.php +++ b/src/WP_CLI/CommandWithTranslation.php @@ -249,8 +249,8 @@ protected function download_language_pack( $download, $slug = null ) { * @return array */ protected function get_installed_languages( $slug = 'default' ) { - $available = wp_get_installed_translations( $this->obj_type ); - $available = ! empty( $available[ $slug ] ) ? array_keys( $available[ $slug ] ) : array(); + $available = wp_get_installed_translations( $this->obj_type ); + $available = ! empty( $available[ $slug ] ) ? array_keys( $available[ $slug ] ) : array(); return $available; } From 0f680e7ee05bc99480c84662b408c050be9fd8a3 Mon Sep 17 00:00:00 2001 From: Erika Gili Date: Thu, 13 Jun 2024 14:01:57 +0200 Subject: [PATCH 3/5] Set dafault available language only for core --- src/WP_CLI/CommandWithTranslation.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/WP_CLI/CommandWithTranslation.php b/src/WP_CLI/CommandWithTranslation.php index c3e06e73..7e4307a0 100644 --- a/src/WP_CLI/CommandWithTranslation.php +++ b/src/WP_CLI/CommandWithTranslation.php @@ -251,6 +251,9 @@ protected function download_language_pack( $download, $slug = null ) { protected function get_installed_languages( $slug = 'default' ) { $available = wp_get_installed_translations( $this->obj_type ); $available = ! empty( $available[ $slug ] ) ? array_keys( $available[ $slug ] ) : array(); + if ( 'default' === $slug ) { + $available[] = 'en_US'; + } return $available; } From 35070db248f0fe3fc49a0b9fcb215231897f52e1 Mon Sep 17 00:00:00 2001 From: Erika Gili Date: Thu, 13 Jun 2024 15:00:33 +0200 Subject: [PATCH 4/5] Update theme test --- features/language-theme.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/language-theme.feature b/features/language-theme.feature index b210ae8e..1a6623da 100644 --- a/features/language-theme.feature +++ b/features/language-theme.feature @@ -119,7 +119,7 @@ Feature: Manage translation files for a WordPress install | language | english_name | status | | cs_CZ | Czech | installed | | de_DE | German | installed | - | en_US | English (United States) | installed | + | en_US | English (United States) | uninstalled | | en_GB | English (UK) | active | When I run `wp language theme uninstall twentyten cs_CZ de_DE` From d38e2df04f36cd4bf7af261a28be1bd66f26172e Mon Sep 17 00:00:00 2001 From: Erika Gili Date: Thu, 13 Jun 2024 16:19:15 +0200 Subject: [PATCH 5/5] Remove tests on en_US language --- features/language-plugin.feature | 3 --- features/language-theme.feature | 3 --- src/WP_CLI/CommandWithTranslation.php | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/features/language-plugin.feature b/features/language-plugin.feature index c55a6647..2d4cb6ea 100644 --- a/features/language-plugin.feature +++ b/features/language-plugin.feature @@ -17,7 +17,6 @@ Feature: Manage translation files for a WordPress install | language | english_name | status | | cs_CZ | Czech | uninstalled | | de_DE | German | uninstalled | - | en_US | English (United States) | active | | en_GB | English (UK) | uninstalled | When I try `wp language plugin list not-a-plugin --format=json` @@ -85,7 +84,6 @@ Feature: Manage translation files for a WordPress install | language | english_name | status | | cs_CZ | Czech | installed | | de_DE | German | installed | - | en_US | English (United States) | active | | en_GB | English (UK) | installed | When I run `wp language plugin list hello-dolly --fields=language,english_name,update` @@ -93,7 +91,6 @@ Feature: Manage translation files for a WordPress install | language | english_name | update | | cs_CZ | Czech | none | | de_DE | German | none | - | en_US | English (United States) | none | | en_GB | English (UK) | none | When I run `wp language plugin list hello-dolly --status=installed --format=count` diff --git a/features/language-theme.feature b/features/language-theme.feature index 1a6623da..ef9cb7de 100644 --- a/features/language-theme.feature +++ b/features/language-theme.feature @@ -16,7 +16,6 @@ Feature: Manage translation files for a WordPress install | language | english_name | status | | cs_CZ | Czech | uninstalled | | de_DE | German | uninstalled | - | en_US | English (United States) | active | | en_GB | English (UK) | uninstalled | When I try `wp language theme list not-a-theme --format=json` @@ -85,7 +84,6 @@ Feature: Manage translation files for a WordPress install | cs_CZ | Czech | installed | | de_DE | German | installed | | en_GB | English (UK) | installed | - | en_US | English (United States) | active | When I run `wp language theme list twentyten --fields=language,english_name,update` Then STDOUT should be a table containing rows: @@ -119,7 +117,6 @@ Feature: Manage translation files for a WordPress install | language | english_name | status | | cs_CZ | Czech | installed | | de_DE | German | installed | - | en_US | English (United States) | uninstalled | | en_GB | English (UK) | active | When I run `wp language theme uninstall twentyten cs_CZ de_DE` diff --git a/src/WP_CLI/CommandWithTranslation.php b/src/WP_CLI/CommandWithTranslation.php index 7e4307a0..96ab675e 100644 --- a/src/WP_CLI/CommandWithTranslation.php +++ b/src/WP_CLI/CommandWithTranslation.php @@ -251,7 +251,7 @@ protected function download_language_pack( $download, $slug = null ) { protected function get_installed_languages( $slug = 'default' ) { $available = wp_get_installed_translations( $this->obj_type ); $available = ! empty( $available[ $slug ] ) ? array_keys( $available[ $slug ] ) : array(); - if ( 'default' === $slug ) { + if ( 'core' === $this->obj_type ) { $available[] = 'en_US'; }