Wordpress - Override default WordPress core translation

You could use gettext filter:

add_filter( 'gettext', 'cyb_filter_gettext', 10, 3 );
function cyb_filter_gettext( $translated, $original, $domain ) {

    // Use the text string exactly as it is in the translation file
    if ( $translated == "Categorie: %s" ) {
        $translated = "Sectie: %s";
    }

    return $translated;
}

If you need to filter a translation with context, use gettext_with_context filter:

add_filter( 'gettext_with_context', 'cyb_filter_gettext_with_context', 10, 4 );
function cyb_filter_gettext_with_context( $translated, $original, $context, $domain ) {

    // Use the text string exactly as it is in the translation file
    if ( $translated == "Categorie: %s" ) {
        $translated = "Sectie: %s";
    }

    return $translated;
}

A translation with context means that a context is given in the gettext function used to translate the string. For example, this is without context:

$translated = __( 'Search', 'textdomain' );

And this is with context:

$translated = _x( 'Search', 'form placeholder', 'textdomain' );

Similar filters are available for plural translations ([_n()][2] and [_nx()][2]): ngettext and ngettext_with_context.


It's also possible to use get_the_archive_title filter in your functions.php:

function archive_title_modify( $title ) {
    return str_replace('Categorie: ', 'Sectie: ', $title);
}
add_filter('get_the_archive_title', 'archive_title_modify');

The advantage is that it's called only once per page, instead on every translated string as with gettext filter.