Yard DeepL
This plugin registers secure API endpoints that allow you to request translations directly from DeepL without exposing your DeepL API-key. These endpoints are only accessible when a valid nonce is provided. When providing translations to website visitors, you can configure which languages are suppor
This plugin registers secure API endpoints that allow you to request translations directly from DeepL without exposing your DeepL API-key. These endpoints are only accessible when a valid nonce is provided. When providing translations to website visitors, you can configure which languages are supported for translation.
Caching Mechanism
Each object that is translated will store its cached translation in the wp_postmeta table within the database. This caching mechanism ensures that translations are efficiently reused, reducing unnecessary API requests to DeepL and saving costs.
- Serving Cached Translations: Translations are cached per text. If a cached translation is newer than the post_modified date of the object, every requested text found in the cache is served from it. Texts that are not cached yet (for example a changed menu or footer) are fetched from DeepL and merged into the cache. The response contains exactly the requested texts.
- Fetching New Translations: When the post_modified date of the object is more recent than the cached translation, a new translation is fetched from DeepL. Once retrieved, this translation is immediately cached for future use.
- Cache Authorization: Only logged-in users with the edit_posts capability (or a custom capability configured via the yard::deepl/cache_capability filter) are permitted to create new cache entries. Requests from users without this capability never write to the cache: texts missing from the cache are translated by DeepL and returned together with the cached texts, without storing the result. When the rate limit is reached, only the cached texts are returned.
This approach minimizes the number of API calls to DeepL, ensuring translations are kept up to date only when necessary.
Admin: Cache Metabox
A metabox labeled Yard DeepL is displayed on the edit screen of supported post types (default: all public post types except attachment). It provides two options:
- Disable translation cache: When checked, the cache is bypassed for this object. Useful for posts with dynamic content that should always be translated fresh.
- Clear translation cache: When checked and the post is saved, all cached translations for this object are deleted.