diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9765a2e..9a6200f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed
+- **Bulgarian status labels no longer mix singular and plural** — the campaign queue showed a single campaign as "Завършена" (feminine singular) next to "Отменени" (plural), because one string served both the status badge of a single item and the filter links that count many. Status, type and subscriber labels that describe a single row now use context-qualified strings (`_x()`), so Bulgarian can render campaign badges as feminine singular ("Завършена", "Отменена", "Насрочена"), email badges as masculine singular ("Изпратен", "Неуспешен", "Отменен") and the filter links as plural ("Завършени", "Отменени", "Насрочени"). German keeps its existing wording, and the date columns "Sent"/"Opened"/"Scheduled" now read as column headers ("Изпратен на", "Gesendet am") instead of as filter labels.
### Security
diff --git a/admin/partials/dashboard.php b/admin/partials/dashboard.php
index 3424957..814d61d 100644
--- a/admin/partials/dashboard.php
+++ b/admin/partials/dashboard.php
@@ -160,7 +160,7 @@
-
+
' . esc_html( date_i18n( 'd.m.Y H:i:s', $next_cron ) ) . '' );
@@ -168,7 +168,7 @@
-
+
diff --git a/admin/partials/queue-detail.php b/admin/partials/queue-detail.php
index d51a0ee..225ca13 100644
--- a/admin/partials/queue-detail.php
+++ b/admin/partials/queue-detail.php
@@ -169,16 +169,16 @@
__( 'Pending', 'mail-system' ),
- 'processing' => __( 'Processing', 'mail-system' ),
- 'completed' => __( 'Completed', 'mail-system' ),
- 'cancelled' => __( 'Cancelled', 'mail-system' ),
+ 'pending' => _x( 'Pending', 'campaign status', 'mail-system' ),
+ 'processing' => _x( 'Processing', 'campaign status', 'mail-system' ),
+ 'completed' => _x( 'Completed', 'campaign status', 'mail-system' ),
+ 'cancelled' => _x( 'Cancelled', 'campaign status', 'mail-system' ),
);
echo esc_html( $statuses[ $campaign->status ] ?? $campaign->status );
?>
type === 'one_time' ) : ?>
-
+
@@ -413,8 +413,8 @@ class="">
-
-
+
+
@@ -456,11 +456,11 @@ class="">
__( 'Pending', 'mail-system' ),
- 'processing' => __( 'Processing', 'mail-system' ),
- 'sent' => __( 'Sent', 'mail-system' ),
- 'failed' => __( 'Failed', 'mail-system' ),
- 'cancelled' => __( 'Cancelled', 'mail-system' ),
+ 'pending' => _x( 'Pending', 'email status', 'mail-system' ),
+ 'processing' => _x( 'Processing', 'email status', 'mail-system' ),
+ 'sent' => _x( 'Sent', 'email status', 'mail-system' ),
+ 'failed' => _x( 'Failed', 'email status', 'mail-system' ),
+ 'cancelled' => _x( 'Cancelled', 'email status', 'mail-system' ),
);
echo esc_html( $item_statuses[ $item->status ] ?? $item->status );
?>
diff --git a/admin/partials/queue-legacy.php b/admin/partials/queue-legacy.php
index a2d8434..6c34769 100644
--- a/admin/partials/queue-legacy.php
+++ b/admin/partials/queue-legacy.php
@@ -123,8 +123,8 @@ class="">
-
-
+
+
@@ -167,17 +167,17 @@ class="">
__( 'Pending', 'mail-system' ),
- 'processing' => __( 'Processing', 'mail-system' ),
- 'sent' => __( 'Sent', 'mail-system' ),
- 'failed' => __( 'Failed', 'mail-system' ),
- 'cancelled' => __( 'Cancelled', 'mail-system' ),
+ 'pending' => _x( 'Pending', 'email status', 'mail-system' ),
+ 'processing' => _x( 'Processing', 'email status', 'mail-system' ),
+ 'sent' => _x( 'Sent', 'email status', 'mail-system' ),
+ 'failed' => _x( 'Failed', 'email status', 'mail-system' ),
+ 'cancelled' => _x( 'Cancelled', 'email status', 'mail-system' ),
);
echo esc_html( $statuses[ $item->status ] ?? $item->status );
?>
status === 'pending' ) : ?>
-
+
status === 'failed' && $item->error_message ) : ?>
error_message ); ?>
diff --git a/admin/partials/queue.php b/admin/partials/queue.php
index 4c6bd29..63468bf 100644
--- a/admin/partials/queue.php
+++ b/admin/partials/queue.php
@@ -281,7 +281,7 @@ class="">
type === 'one_time' ) : ?>
-
+
@@ -337,16 +337,16 @@ class="">
__( 'Pending', 'mail-system' ),
- 'processing' => __( 'Processing', 'mail-system' ),
- 'completed' => __( 'Completed', 'mail-system' ),
- 'cancelled' => __( 'Cancelled', 'mail-system' ),
+ 'pending' => _x( 'Pending', 'campaign status', 'mail-system' ),
+ 'processing' => _x( 'Processing', 'campaign status', 'mail-system' ),
+ 'completed' => _x( 'Completed', 'campaign status', 'mail-system' ),
+ 'cancelled' => _x( 'Cancelled', 'campaign status', 'mail-system' ),
);
echo esc_html( $statuses[ $campaign->status ] ?? $campaign->status );
?>
status === 'pending' ) : ?>
-
+
diff --git a/admin/partials/subscribers.php b/admin/partials/subscribers.php
index f0747fc..de9f5eb 100644
--- a/admin/partials/subscribers.php
+++ b/admin/partials/subscribers.php
@@ -105,13 +105,13 @@
status : 'active', 'active' ); ?>>
-
+
status : '', 'inactive' ); ?>>
-
+
status : '', 'unsubscribed' ); ?>>
-
+
@@ -386,9 +386,9 @@ class="">
esc_html__( 'Active', 'mail-system' ),
- 'inactive' => esc_html__( 'Inactive', 'mail-system' ),
- 'unsubscribed' => esc_html__( 'Unsubscribed', 'mail-system' ),
+ 'active' => _x( 'Active', 'subscriber status', 'mail-system' ),
+ 'inactive' => _x( 'Inactive', 'subscriber status', 'mail-system' ),
+ 'unsubscribed' => _x( 'Unsubscribed', 'subscriber status', 'mail-system' ),
);
echo esc_html( $statuses[ $sub->status ] ?? $sub->status );
?>
diff --git a/includes/Admin/class-admin-assets.php b/includes/Admin/class-admin-assets.php
index 7f73573..cbadf8b 100644
--- a/includes/Admin/class-admin-assets.php
+++ b/includes/Admin/class-admin-assets.php
@@ -173,8 +173,8 @@ private function get_localized_strings(): array {
'copy_error' => __( 'Copy failed', 'mail-system' ),
'no_subscribers_selected' => __( 'No subscribers selected.', 'mail-system' ),
'no_lists_selected' => __( 'No lists selected.', 'mail-system' ),
- 'status_active' => __( 'Active', 'mail-system' ),
- 'status_inactive' => __( 'Inactive', 'mail-system' ),
+ 'status_active' => _x( 'Active', 'subscriber status', 'mail-system' ),
+ 'status_inactive' => _x( 'Inactive', 'subscriber status', 'mail-system' ),
);
}
}
diff --git a/languages/mail-system-bg_BG.mo b/languages/mail-system-bg_BG.mo
index bb08eb7..b114572 100644
Binary files a/languages/mail-system-bg_BG.mo and b/languages/mail-system-bg_BG.mo differ
diff --git a/languages/mail-system-bg_BG.po b/languages/mail-system-bg_BG.po
index ef4cadb..f501fc9 100644
--- a/languages/mail-system-bg_BG.po
+++ b/languages/mail-system-bg_BG.po
@@ -327,7 +327,7 @@ msgstr "Cron статус"
#: admin/partials/dashboard.php
msgid "Active"
-msgstr "Активен"
+msgstr "Активни"
#: admin/partials/dashboard.php
msgid "Next run: %s"
@@ -335,7 +335,7 @@ msgstr "Следващо изпълнение: %s"
#: admin/partials/dashboard.php
msgid "Inactive"
-msgstr "Неактивен"
+msgstr "Неактивни"
#: admin/partials/dashboard.php
msgid "Sending: %d emails/min"
@@ -367,7 +367,7 @@ msgstr "Статус"
#: admin/partials/subscribers.php
msgid "Unsubscribed"
-msgstr "Отписан"
+msgstr "Отписани"
#: admin/partials/subscribers.php
msgid "No lists created."
@@ -546,11 +546,11 @@ msgstr "%d имейла/мин"
#: admin/partials/queue.php
msgid "Scheduled"
-msgstr "Насрочен"
+msgstr "Насрочени"
#: admin/partials/queue.php
msgid "Pending"
-msgstr "Чакащ"
+msgstr "Чакащи"
#: admin/partials/queue.php
msgid "Processing"
@@ -1154,7 +1154,7 @@ msgstr ""
#: admin/partials/queue.php
msgid "Completed"
-msgstr "Завършена"
+msgstr "Завършени"
#: admin/partials/queue.php
msgid "Campaigns"
@@ -2994,3 +2994,103 @@ msgstr "Достъпът за запис изисква обхват за чет
#: admin/partials/api-access.php:74
msgid "e.g. Newsletter scheduler"
msgstr "напр. Планировчик на бюлетини"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Pending"
+msgstr "Чакаща"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Processing"
+msgstr "В процес"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Completed"
+msgstr "Завършена"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Cancelled"
+msgstr "Отменена"
+
+#: admin/partials/queue.php
+msgctxt "campaign status"
+msgid "Scheduled"
+msgstr "Насрочена"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Pending"
+msgstr "Чакащ"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Processing"
+msgstr "В процес"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Sent"
+msgstr "Изпратен"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Failed"
+msgstr "Неуспешен"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Cancelled"
+msgstr "Отменен"
+
+#: admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Scheduled"
+msgstr "Насрочен"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign type"
+msgid "One-time"
+msgstr "Еднократна"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "table column header"
+msgid "Sent"
+msgstr "Изпратен на"
+
+#: admin/partials/queue-detail.php
+msgctxt "table column header"
+msgid "Opened"
+msgstr "Отворен на"
+
+#: admin/partials/queue-legacy.php
+msgctxt "table column header"
+msgid "Scheduled"
+msgstr "Насрочен за"
+
+#: admin/partials/subscribers.php, includes/Admin/class-admin-assets.php
+msgctxt "subscriber status"
+msgid "Active"
+msgstr "Активен"
+
+#: admin/partials/subscribers.php, includes/Admin/class-admin-assets.php
+msgctxt "subscriber status"
+msgid "Inactive"
+msgstr "Неактивен"
+
+#: admin/partials/subscribers.php
+msgctxt "subscriber status"
+msgid "Unsubscribed"
+msgstr "Отписан"
+
+#: admin/partials/dashboard.php
+msgctxt "cron status"
+msgid "Active"
+msgstr "Активен"
+
+#: admin/partials/dashboard.php
+msgctxt "cron status"
+msgid "Inactive"
+msgstr "Неактивен"
diff --git a/languages/mail-system-de_DE.mo b/languages/mail-system-de_DE.mo
index 55c3225..4274311 100644
Binary files a/languages/mail-system-de_DE.mo and b/languages/mail-system-de_DE.mo differ
diff --git a/languages/mail-system-de_DE.po b/languages/mail-system-de_DE.po
index 87ce5d8..96d65db 100644
--- a/languages/mail-system-de_DE.po
+++ b/languages/mail-system-de_DE.po
@@ -3037,3 +3037,103 @@ msgstr "Schreibzugriff erfordert den Lese-Geltungsbereich für die entsprechende
#: admin/partials/api-access.php:74
msgid "e.g. Newsletter scheduler"
msgstr "z. B. Newsletter-Planer"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Pending"
+msgstr "Ausstehend"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Processing"
+msgstr "In Bearbeitung"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Completed"
+msgstr "Abgeschlossen"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Cancelled"
+msgstr "Abgebrochen"
+
+#: admin/partials/queue.php
+msgctxt "campaign status"
+msgid "Scheduled"
+msgstr "Geplant"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Pending"
+msgstr "Ausstehend"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Processing"
+msgstr "In Bearbeitung"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Sent"
+msgstr "Gesendet"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Failed"
+msgstr "Fehlgeschlagen"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Cancelled"
+msgstr "Abgebrochen"
+
+#: admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Scheduled"
+msgstr "Geplant"
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign type"
+msgid "One-time"
+msgstr "Einmalig"
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "table column header"
+msgid "Sent"
+msgstr "Gesendet am"
+
+#: admin/partials/queue-detail.php
+msgctxt "table column header"
+msgid "Opened"
+msgstr "Geöffnet am"
+
+#: admin/partials/queue-legacy.php
+msgctxt "table column header"
+msgid "Scheduled"
+msgstr "Geplant für"
+
+#: admin/partials/subscribers.php, includes/Admin/class-admin-assets.php
+msgctxt "subscriber status"
+msgid "Active"
+msgstr "Aktiv"
+
+#: admin/partials/subscribers.php, includes/Admin/class-admin-assets.php
+msgctxt "subscriber status"
+msgid "Inactive"
+msgstr "Inaktiv"
+
+#: admin/partials/subscribers.php
+msgctxt "subscriber status"
+msgid "Unsubscribed"
+msgstr "Abgemeldet"
+
+#: admin/partials/dashboard.php
+msgctxt "cron status"
+msgid "Active"
+msgstr "Aktiv"
+
+#: admin/partials/dashboard.php
+msgctxt "cron status"
+msgid "Inactive"
+msgstr "Inaktiv"
diff --git a/languages/mail-system.pot b/languages/mail-system.pot
index b4fc7e6..e8a9a92 100644
--- a/languages/mail-system.pot
+++ b/languages/mail-system.pot
@@ -2981,3 +2981,103 @@ msgstr ""
#: admin/partials/api-access.php:74
msgid "e.g. Newsletter scheduler"
msgstr ""
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Pending"
+msgstr ""
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Processing"
+msgstr ""
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Completed"
+msgstr ""
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign status"
+msgid "Cancelled"
+msgstr ""
+
+#: admin/partials/queue.php
+msgctxt "campaign status"
+msgid "Scheduled"
+msgstr ""
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Pending"
+msgstr ""
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Processing"
+msgstr ""
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Sent"
+msgstr ""
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Failed"
+msgstr ""
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Cancelled"
+msgstr ""
+
+#: admin/partials/queue-legacy.php
+msgctxt "email status"
+msgid "Scheduled"
+msgstr ""
+
+#: admin/partials/queue.php, admin/partials/queue-detail.php
+msgctxt "campaign type"
+msgid "One-time"
+msgstr ""
+
+#: admin/partials/queue-detail.php, admin/partials/queue-legacy.php
+msgctxt "table column header"
+msgid "Sent"
+msgstr ""
+
+#: admin/partials/queue-detail.php
+msgctxt "table column header"
+msgid "Opened"
+msgstr ""
+
+#: admin/partials/queue-legacy.php
+msgctxt "table column header"
+msgid "Scheduled"
+msgstr ""
+
+#: admin/partials/subscribers.php, includes/Admin/class-admin-assets.php
+msgctxt "subscriber status"
+msgid "Active"
+msgstr ""
+
+#: admin/partials/subscribers.php, includes/Admin/class-admin-assets.php
+msgctxt "subscriber status"
+msgid "Inactive"
+msgstr ""
+
+#: admin/partials/subscribers.php
+msgctxt "subscriber status"
+msgid "Unsubscribed"
+msgstr ""
+
+#: admin/partials/dashboard.php
+msgctxt "cron status"
+msgid "Active"
+msgstr ""
+
+#: admin/partials/dashboard.php
+msgctxt "cron status"
+msgid "Inactive"
+msgstr ""
diff --git a/tests/Unit/class-statustranslationstest.php b/tests/Unit/class-statustranslationstest.php
new file mode 100644
index 0000000..85e59db
--- /dev/null
+++ b/tests/Unit/class-statustranslationstest.php
@@ -0,0 +1,185 @@
+collect_context_calls();
+
+ $this->assertNotEmpty( $used, 'No _x() calls were found — the scanner is broken.' );
+
+ foreach ( self::CATALOGUES as $catalogue ) {
+ $entries = $this->parse_catalogue( $catalogue );
+
+ foreach ( $used as $key => $location ) {
+ $this->assertArrayHasKey(
+ $key,
+ $entries,
+ sprintf( '%s is missing the entry for %s (used in %s).', $catalogue, $key, $location )
+ );
+ }
+ }
+ }
+
+ /**
+ * Translated locales leave no context-qualified string empty.
+ */
+ public function test_translated_locales_have_no_empty_context_strings(): void {
+ $used = $this->collect_context_calls();
+
+ foreach ( array( 'languages/mail-system-bg_BG.po', 'languages/mail-system-de_DE.po' ) as $catalogue ) {
+ $entries = $this->parse_catalogue( $catalogue );
+
+ foreach ( array_keys( $used ) as $key ) {
+ $this->assertNotSame(
+ '',
+ $entries[ $key ] ?? '',
+ sprintf( '%s has no translation for %s.', $catalogue, $key )
+ );
+ }
+ }
+ }
+
+ /**
+ * Bulgarian campaign badges agree with "кампания" (feminine singular).
+ */
+ public function test_bulgarian_campaign_statuses_are_feminine_singular(): void {
+ $entries = $this->parse_catalogue( 'languages/mail-system-bg_BG.po' );
+
+ $this->assertSame( 'Чакаща', $entries['campaign status' . "\x04" . 'Pending'] );
+ $this->assertSame( 'Завършена', $entries['campaign status' . "\x04" . 'Completed'] );
+ $this->assertSame( 'Отменена', $entries['campaign status' . "\x04" . 'Cancelled'] );
+ $this->assertSame( 'Насрочена', $entries['campaign status' . "\x04" . 'Scheduled'] );
+ }
+
+ /**
+ * Bulgarian email badges agree with "имейл" (masculine singular).
+ */
+ public function test_bulgarian_email_statuses_are_masculine_singular(): void {
+ $entries = $this->parse_catalogue( 'languages/mail-system-bg_BG.po' );
+
+ $this->assertSame( 'Чакащ', $entries['email status' . "\x04" . 'Pending'] );
+ $this->assertSame( 'Изпратен', $entries['email status' . "\x04" . 'Sent'] );
+ $this->assertSame( 'Неуспешен', $entries['email status' . "\x04" . 'Failed'] );
+ $this->assertSame( 'Отменен', $entries['email status' . "\x04" . 'Cancelled'] );
+ }
+
+ /**
+ * Bulgarian filter links stay plural, since they label a count of items.
+ */
+ public function test_bulgarian_uncontextualised_statuses_are_plural(): void {
+ $entries = $this->parse_catalogue( 'languages/mail-system-bg_BG.po' );
+
+ $this->assertSame( 'Чакащи', $entries['Pending'] );
+ $this->assertSame( 'Изпратени', $entries['Sent'] );
+ $this->assertSame( 'Неуспешни', $entries['Failed'] );
+ $this->assertSame( 'Отменени', $entries['Cancelled'] );
+ $this->assertSame( 'Завършени', $entries['Completed'] );
+ $this->assertSame( 'Насрочени', $entries['Scheduled'] );
+ $this->assertSame( 'Активни', $entries['Active'] );
+ $this->assertSame( 'Отписани', $entries['Unsubscribed'] );
+ }
+
+ /**
+ * Collect every _x()/esc_html_x()/esc_attr_x() call in the plugin sources.
+ *
+ * @return array Map of "context\x04msgid" to the file it was found in.
+ */
+ private function collect_context_calls(): array {
+ $found = array();
+
+ foreach ( self::SOURCE_DIRS as $dir ) {
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator( MSKD_PLUGIN_DIR . $dir )
+ );
+
+ foreach ( $iterator as $file ) {
+ if ( 'php' !== $file->getExtension() ) {
+ continue;
+ }
+
+ $contents = file_get_contents( $file->getPathname() );
+ $matches = array();
+
+ preg_match_all(
+ "/(?:esc_html_x|esc_attr_x|_x)\(\s*'([^']+)'\s*,\s*'([^']+)'\s*,\s*'mail-system'\s*\)/",
+ $contents,
+ $matches,
+ PREG_SET_ORDER
+ );
+
+ foreach ( $matches as $match ) {
+ $found[ $match[2] . "\x04" . $match[1] ] = $dir . '/' . $file->getFilename();
+ }
+ }
+ }
+
+ return $found;
+ }
+
+ /**
+ * Parse a PO/POT file into a map of message keys to translations.
+ *
+ * Keys are the msgid, prefixed with "context\x04" when the entry carries a msgctxt.
+ *
+ * @param string $relative_path Catalogue path relative to the plugin root.
+ * @return array Map of message keys to translations.
+ */
+ private function parse_catalogue( string $relative_path ): array {
+ $lines = file( MSKD_PLUGIN_DIR . $relative_path, FILE_IGNORE_NEW_LINES );
+ $entries = array();
+ $context = null;
+ $msgid = null;
+
+ foreach ( $lines as $line ) {
+ if ( 1 === preg_match( '/^msgctxt "(.*)"$/', $line, $match ) ) {
+ $context = stripcslashes( $match[1] );
+ } elseif ( 1 === preg_match( '/^msgid "(.*)"$/', $line, $match ) ) {
+ $msgid = stripcslashes( $match[1] );
+ } elseif ( 1 === preg_match( '/^msgstr "(.*)"$/', $line, $match ) && null !== $msgid && '' !== $msgid ) {
+ $key = null === $context ? $msgid : $context . "\x04" . $msgid;
+ $entries[ $key ] = stripcslashes( $match[1] );
+ $context = null;
+ $msgid = null;
+ }
+ }
+
+ return $entries;
+ }
+}
diff --git a/tests/Unit/class-testcase.php b/tests/Unit/class-testcase.php
index 238e4ae..034d73e 100644
--- a/tests/Unit/class-testcase.php
+++ b/tests/Unit/class-testcase.php
@@ -75,19 +75,28 @@ protected function setup_common_wp_functions(): void {
// Translation functions.
Functions\stubs(
array(
- '__' => function ( $text, $domain = 'default' ) {
+ '__' => function ( $text, $domain = 'default' ) {
return $text;
},
- '_e' => function ( $text, $domain = 'default' ) {
+ '_e' => function ( $text, $domain = 'default' ) {
echo $text;
},
- 'esc_html_e' => function ( $text, $domain = 'default' ) {
+ '_x' => function ( $text, $context, $domain = 'default' ) {
+ return $text;
+ },
+ 'esc_html_e' => function ( $text, $domain = 'default' ) {
echo $text;
},
- 'esc_html__' => function ( $text, $domain = 'default' ) {
+ 'esc_html__' => function ( $text, $domain = 'default' ) {
+ return $text;
+ },
+ 'esc_html_x' => function ( $text, $context, $domain = 'default' ) {
+ return $text;
+ },
+ 'esc_attr__' => function ( $text, $domain = 'default' ) {
return $text;
},
- 'esc_attr__' => function ( $text, $domain = 'default' ) {
+ 'esc_attr_x' => function ( $text, $context, $domain = 'default' ) {
return $text;
},
)