Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ A metabox labeled **Yard DeepL** is displayed on the edit screen of supported po

### Admin: Translation Cache Column

A **Translation cache** column is added to the post list screen of all supported post types. Its purpose is to notify editors which posts should be cached as soon as possible to avoid unnecessary DeepL API costs.
A **Cache** column can be added to the post list screen of all supported post types. It is off by default; enable it under **Settings > Yard DeepL > Translation cache column**. Its purpose is to notify editors which posts should be cached as soon as possible to avoid unnecessary DeepL API costs.

- **Green badge per language** (e.g. `NL`, `EN-US`): a valid, up-to-date cached translation exists for that language. Visitor requests are served from cache at no cost.
- **Yellow badge with a count per language** (e.g. `EN-US 3`): a cached translation exists, but that many visitor requests received only part of their texts because the rest is missing from the cache. Hovering the badge shows the full count as a tooltip. An editor visiting the page translates the missing texts, stores them and resets the count.
Expand Down
12 changes: 8 additions & 4 deletions assets/css/admin-columns.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
.fixed .column-ydpl_translation_cache {
width: 6%;
}

.ydpl-cache-badges {
display: flex;
flex-wrap: wrap;
gap: 3px;
gap: 2px;
}

.ydpl-cache-badge {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 10px;
gap: 3px;
font-size: 9px;
line-height: 1;
padding: 3px 6px;
padding: 2px 4px;
border-radius: 3px;
font-weight: 600;
letter-spacing: 0.03em;
Expand Down
2 changes: 1 addition & 1 deletion dist/admin-columns.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '0921bcaa4b4ca4ac535b');
<?php return array('dependencies' => array(), 'version' => '48a94204d54696f323e5');
2 changes: 1 addition & 1 deletion dist/admin-columns.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified languages/yard-deepl-nl_NL.mo
Binary file not shown.
82 changes: 46 additions & 36 deletions languages/yard-deepl-nl_NL.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2026-07-31T00:00:00+00:00\n"
"PO-Revision-Date: 2026-07-31T00:00:00+00:00\n"
"PO-Revision-Date: 2026-11-10T15:32:27+00:00\n"
"Language: \n"

#. Plugin Name of the plugin
#: yard-deepl.php:8
#: src/Providers/MetaBoxServiceProvider.php:35
#: src/Providers/MetaBoxServiceProvider.php:38
#: src/Providers/SettingsServiceProvider.php:44
#: src/Providers/SettingsServiceProvider.php:45
msgid "Yard DeepL"
Expand Down Expand Up @@ -166,19 +166,51 @@ msgstr "Chinees (vereenvoudigd)"
msgid "Chinese (Traditional)"
msgstr "Chinees (traditioneel)"

#: src/Providers/MetaBoxServiceProvider.php:72
#: src/Controllers/SettingsController.php:116
msgid "The DeepL API base URL must be a valid https://*.deepl.com/v2/translate URL. The previous value has been kept."
msgstr "De DeepL API basis-URL moet een geldige https://*.deepl.com/v2/translate-URL zijn. De vorige waarde is behouden."

#: src/Providers/AdminColumnsServiceProvider.php:68
msgid "Cache"
msgstr "Cache"

#: src/Providers/AdminColumnsServiceProvider.php:85
msgid "No languages configured"
msgstr "Geen talen geconfigureerd"

#. translators: %d: number of visitor requests that received only part of their texts from the cache
#: src/Providers/AdminColumnsServiceProvider.php:105
#, php-format
msgid "%d incomplete response"
msgid_plural "%d incomplete responses"
msgstr[0] "%d onvolledig antwoord"
msgstr[1] "%d onvolledige antwoorden"

#. translators: %d: number of uncached DeepL API calls made for this post and language
#: src/Providers/AdminColumnsServiceProvider.php:124
#, php-format
msgid "%d uncached call"
msgid_plural "%d uncached calls"
msgstr[0] "%d aanroep zonder cache"
msgstr[1] "%d aanroepen zonder cache"

#: src/Providers/AdminColumnsServiceProvider.php:135
msgid "No cached translations"
msgstr "Geen gecachede vertalingen"

#: src/Providers/MetaBoxServiceProvider.php:75
msgid "Disable translation cache when this object contains dynamic content."
msgstr "Schakel de vertalingscache uit wanneer dit object dynamische inhoud bevat."

#: src/Providers/MetaBoxServiceProvider.php:75
#: src/Providers/MetaBoxServiceProvider.php:78
msgid "Disable translation cache?"
msgstr "Vertalingscache uitschakelen?"

#: src/Providers/MetaBoxServiceProvider.php:78
#: src/Providers/MetaBoxServiceProvider.php:81
msgid "Clear cached translations on save."
msgstr "Verwijder vertaalcache bij opslaan."

#: src/Providers/MetaBoxServiceProvider.php:81
#: src/Providers/MetaBoxServiceProvider.php:84
msgid "Clear translation cache?"
msgstr "Vertaalcache wissen?"

Expand All @@ -198,14 +230,14 @@ msgstr "DeepL API-sleutel"
msgid "DeepL supported languages"
msgstr "DeepL ondersteunde talen"

#: src/Providers/SettingsServiceProvider.php:110
#: src/Providers/SettingsServiceProvider.php:103
msgid "Translation cache column"
msgstr "Vertaalcache-kolom"

#: src/Providers/SettingsServiceProvider.php:119
msgid "Parameter object_id mandatory"
msgstr "Parameter object_id verplicht"

#: src/Controllers/SettingsController.php:112
msgid "The DeepL API base URL must be a valid https://*.deepl.com/v2/translate URL. The previous value has been kept."
msgstr "De DeepL API basis-URL moet een geldige https://*.deepl.com/v2/translate-URL zijn. De vorige waarde is behouden."

#. Translators: %s is the URL to the DeepL API documentation page.
#: src/Views/admin/partials/settings/settings-description-general.php:10
msgid "website"
Expand All @@ -217,31 +249,9 @@ msgstr "website"
msgid "To query the DeepL API, an API key is required. You can find more information on their %s."
msgstr "Om de DeepL API te bevragen, is een API-sleutel vereist. Meer informatie vind je op hun %s."

#: src/Providers/AdminColumnsServiceProvider.php:53
msgid "Translation cache"
msgstr "Vertaalcache"

#: src/Providers/AdminColumnsServiceProvider.php:70
msgid "No languages configured"
msgstr "Geen talen geconfigureerd"

#: src/Providers/AdminColumnsServiceProvider.php:105
msgid "No cached translations"
msgstr "Geen gecachede vertalingen"

#. Translators: %d is the number of visitor requests that received only part of their texts from the cache.
#: src/Providers/AdminColumnsServiceProvider.php:90
msgid "%d incomplete response"
msgid_plural "%d incomplete responses"
msgstr[0] "%d onvolledig antwoord"
msgstr[1] "%d onvolledige antwoorden"

#. Translators: %d is the number of uncached DeepL API calls made for this post and language.
#: src/Providers/AdminColumnsServiceProvider.php:109
msgid "%d uncached call"
msgid_plural "%d uncached calls"
msgstr[0] "%d aanroep zonder cache"
msgstr[1] "%d aanroepen zonder cache"
#: src/Views/admin/partials/settings/settings-fields.php:44
msgid "Show which languages are cached on post list screens"
msgstr "Toon in overzichten welke talen in de cache staan"

#: src/Views/admin/settings-page.php:15
msgid "Save"
Expand Down
80 changes: 45 additions & 35 deletions languages/yard-deepl.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
# This file is distributed under the GPLv2 or later.
msgid ""
msgstr ""
"Project-Id-Version: Yard DeepL 1.1.0\n"
"Project-Id-Version: Yard DeepL 2.2.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/yard-deepl\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2026-07-31T00:00:00+00:00\n"
"POT-Creation-Date: 2026-11-10T15:32:27+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.12.0\n"
"X-Domain: yard-deepl\n"

#. Plugin Name of the plugin
#: yard-deepl.php:8
#: src/Providers/MetaBoxServiceProvider.php:35
#: src/Providers/MetaBoxServiceProvider.php:38
#: src/Providers/SettingsServiceProvider.php:44
#: src/Providers/SettingsServiceProvider.php:45
msgid "Yard DeepL"
Expand Down Expand Up @@ -169,19 +169,51 @@ msgstr ""
msgid "Chinese (Traditional)"
msgstr ""

#: src/Providers/MetaBoxServiceProvider.php:72
msgid "Disable translation cache when this object contains dynamic content."
#: src/Controllers/SettingsController.php:116
msgid "The DeepL API base URL must be a valid https://*.deepl.com/v2/translate URL. The previous value has been kept."
msgstr ""

#: src/Providers/AdminColumnsServiceProvider.php:68
msgid "Cache"
msgstr ""

#: src/Providers/AdminColumnsServiceProvider.php:85
msgid "No languages configured"
msgstr ""

#. translators: %d: number of visitor requests that received only part of their texts from the cache
#: src/Providers/AdminColumnsServiceProvider.php:105
#, php-format
msgid "%d incomplete response"
msgid_plural "%d incomplete responses"
msgstr[0] ""
msgstr[1] ""

#. translators: %d: number of uncached DeepL API calls made for this post and language
#: src/Providers/AdminColumnsServiceProvider.php:124
#, php-format
msgid "%d uncached call"
msgid_plural "%d uncached calls"
msgstr[0] ""
msgstr[1] ""

#: src/Providers/AdminColumnsServiceProvider.php:135
msgid "No cached translations"
msgstr ""

#: src/Providers/MetaBoxServiceProvider.php:75
msgid "Disable translation cache?"
msgid "Disable translation cache when this object contains dynamic content."
msgstr ""

#: src/Providers/MetaBoxServiceProvider.php:78
msgid "Clear cached translations on save."
msgid "Disable translation cache?"
msgstr ""

#: src/Providers/MetaBoxServiceProvider.php:81
msgid "Clear cached translations on save."
msgstr ""

#: src/Providers/MetaBoxServiceProvider.php:84
msgid "Clear translation cache?"
msgstr ""

Expand All @@ -201,12 +233,12 @@ msgstr ""
msgid "DeepL supported languages"
msgstr ""

#: src/Providers/SettingsServiceProvider.php:110
msgid "Parameter object_id mandatory"
#: src/Providers/SettingsServiceProvider.php:103
msgid "Translation cache column"
msgstr ""

#: src/Controllers/SettingsController.php:112
msgid "The DeepL API base URL must be a valid https://*.deepl.com/v2/translate URL. The previous value has been kept."
#: src/Providers/SettingsServiceProvider.php:119
msgid "Parameter object_id mandatory"
msgstr ""

#. Translators: %s is the URL to the DeepL API documentation page.
Expand All @@ -220,32 +252,10 @@ msgstr ""
msgid "To query the DeepL API, an API key is required. You can find more information on their %s."
msgstr ""

#: src/Providers/AdminColumnsServiceProvider.php:53
msgid "Translation cache"
msgstr ""

#: src/Providers/AdminColumnsServiceProvider.php:70
msgid "No languages configured"
#: src/Views/admin/partials/settings/settings-fields.php:44
msgid "Show which languages are cached on post list screens"
msgstr ""

#: src/Providers/AdminColumnsServiceProvider.php:105
msgid "No cached translations"
msgstr ""

#. Translators: %d is the number of visitor requests that received only part of their texts from the cache.
#: src/Providers/AdminColumnsServiceProvider.php:90
msgid "%d incomplete response"
msgid_plural "%d incomplete responses"
msgstr[0] ""
msgstr[1] ""

#. Translators: %d is the number of uncached DeepL API calls made for this post and language.
#: src/Providers/AdminColumnsServiceProvider.php:109
msgid "%d uncached call"
msgid_plural "%d uncached calls"
msgstr[0] ""
msgstr[1] ""

#: src/Views/admin/settings-page.php:15
msgid "Save"
msgstr ""
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ A metabox labeled Yard DeepL is displayed on the edit screen of supported post t

= Admin: Translation Cache Column =

A Translation cache column is added to the post list screen of all supported post types. Its purpose is to notify editors which posts should be cached as soon as possible to avoid unnecessary DeepL API costs.
A Cache column can be added to the post list screen of all supported post types. It is off by default; enable it under Settings > Yard DeepL > Translation cache column. Its purpose is to notify editors which posts should be cached as soon as possible to avoid unnecessary DeepL API costs.

* Green badge per language (e.g. NL, EN-US): a valid, up-to-date cached translation exists for that language. Visitor requests are served from cache at no cost.
* Yellow badge with a count per language (e.g. EN-US 3): a cached translation exists, but that many visitor requests received only part of their texts because the rest is missing from the cache. Hovering the badge shows the full count as a tooltip. An editor visiting the page translates the missing texts, stores them and resets the count.
Expand Down
1 change: 1 addition & 0 deletions src/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function section_fields_render( array $args ): void
'supported_languages' => ydpl_resolve_from_container( 'ydpl.supported_target.languages' ),
'configured_supported_languages' => ydpl_resolve_from_container( 'ydpl.site_options' )->configured_supported_languages(),
'rest_api_param_object_id_is_mandatory' => ydpl_resolve_from_container( 'ydpl.site_options' )->rest_api_param_object_id_is_mandatory(),
'admin_column_enabled' => ydpl_resolve_from_container( 'ydpl.site_options' )->admin_column_enabled(),
)
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/Providers/AdminColumnsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* target languages already have a valid, non-stale cached translation so editors
* can spot at a glance which posts will trigger a live DeepL API call.
*
* Off by default: list screens get crowded, so sites opt in on the settings page.
*
* @since 2.0.0
*/
class AdminColumnsServiceProvider implements ServiceProviderInterface
Expand All @@ -37,6 +39,10 @@ public function __construct()
*/
public function register(): void
{
if ( ! ydpl_resolve_from_container( 'ydpl.site_options' )->admin_column_enabled() ) {
return;
}

add_action( 'admin_init', array( $this, 'register_columns' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
}
Expand All @@ -59,7 +65,7 @@ public function register_columns(): void
*/
public function add_column( array $columns ): array
{
$columns['ydpl_translation_cache'] = __( 'Translation cache', 'yard-deepl' );
$columns['ydpl_translation_cache'] = __( 'Cache', 'yard-deepl' );

return $columns;
}
Expand Down
9 changes: 9 additions & 0 deletions src/Providers/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ public function register_settings_options(): void
array( 'settings_field_id' => 'ydpl_supported_target_languages' )
);

add_settings_field(
'ydpl_admin_column_enabled',
__( 'Translation cache column', 'yard-deepl' ),
array( $this->controller, 'section_fields_render' ),
'yard-deepl',
'ydpl_section_general',
array( 'settings_field_id' => 'ydpl_admin_column_enabled' )
);

add_settings_section(
'ydpl_section_rest_api',
'REST API',
Expand Down
8 changes: 8 additions & 0 deletions src/Singletons/SiteOptionsSingleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,12 @@ public function rest_api_param_object_id_is_mandatory(): bool

return 'on' === $value;
}

/**
* @since NEXT
*/
public function admin_column_enabled(): bool
{
return 'on' === ( $this->options['ydpl_admin_column_enabled'] ?? '' );
}
}
8 changes: 8 additions & 0 deletions src/Views/admin/partials/settings/settings-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$supported_languages = is_array( $supported_languages ?? null ) ? $supported_languages : array();
$configured_supported_languages = is_array( $configured_supported_languages ?? null ) ? $configured_supported_languages : array();
$rest_api_param_object_id_is_mandatory = $rest_api_param_object_id_is_mandatory ?? true;
$admin_column_enabled = $admin_column_enabled ?? false;
?>

<?php if ( $settings_field_id === 'ydpl_base_url' ) : ?>
Expand All @@ -36,3 +37,10 @@
<?php if ( $settings_field_id === 'ydpl_rest_api_param_object_id_is_mandatory' ) : ?>
<input type="checkbox" name="ydpl_options[ydpl_rest_api_param_object_id_is_mandatory]" <?php echo $rest_api_param_object_id_is_mandatory ? 'checked' : ''; ?>>
<?php endif; ?>

<?php if ( $settings_field_id === 'ydpl_admin_column_enabled' ) : ?>
<label>
<input type="checkbox" name="ydpl_options[ydpl_admin_column_enabled]" <?php checked( $admin_column_enabled ); ?>>
<?php esc_html_e( 'Show which languages are cached on post list screens', 'yard-deepl' ); ?>
</label>
<?php endif; ?>