Você pode usar o filtro gettext :
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;
}
Se você precisar filtrar uma tradução com contexto, 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;
}
Uma tradução com contexto significa que um contexto é dado na função gettext usada para traduzir a string. Por exemplo, isso é sem contexto:
$translated = __( 'Search', 'textdomain' );
E isso é com contexto:
$translated = _x( 'Search', 'form placeholder', 'textdomain' );
Filtros semelhantes estão disponíveis para traduções no plural ( [_n()][2]
e [_nx()][2]
): ngettext
e ngettext_with_context
.