Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Translate Dublin core meta (or other meta)

Dublin Core is a collection of meta tags to describe your content.These tags are automatically generated. Recognised by states/governments, these are used by directories, Bing, Baidu and Yandex.

Dublin Core is a set of meta tags describing your content (recognised by several search engines and directories). They are not translated by default, but you can register them with the weglot_get_dom_checkers filter.

Translate a single meta (e.g. <meta name="dc.title" content="…" />):

add_filter( 'weglot_get_dom_checkers', 'dublin_core_weglot_dom_check' );
function dublin_core_weglot_dom_check( $dom_checkers ) {
    if ( ! class_exists( 'Dublin_Core_Meta' ) ) {
        class Dublin_Core_Meta extends Weglot\Parser\Check\Dom\AbstractDomChecker {
            const DOM       = 'meta[name="dc.title"]';
            const PROPERTY  = 'content';
            const WORD_TYPE = Weglot\Parser\Definitions\Enum\WordType::META_CONTENT;
        }
    }
    $dom_checkers[] = '\Dublin_Core_Meta';
    return $dom_checkers;
}

To target several meta tags at once, list them in the DOM selector (comma-separated):

const DOM = 'meta[name="dc.title"],meta[name="dc.description"]';

Add the class to $dom_checkers outside the class_exists() check: the filter can run several times in the same request, and the checker must be added every time.

Since Weglot 6.3 these classes live under Weglot\Parser\…. Snippets written with the older Weglot\Client\Api\Enum\WordType keep working.

Last updated