Checking the file /wp-admin/edit-tags.php
, we see that it’s using the function _ex()
to translate the string Description
.
Following _ex
path, we find that it finally uses the filter gettext_with_context
to translate the text. So, it is possible to hook into this and modify the desired string.
The following code is a simplified version of @toscho’s Retranslate
plugin. Please, check the original for a much more versatile code.
Use as a plugin or simply copy the code into your theme’s functions.php
file.
In this example, we have an extra context and replacement.
To solve the OP Question, remove the second array item from both.
Configuration values in $params_71992
:
context
of the string, as seen in/wp-admin/edit-tags.php
replacements
, strings for original and desired translationtaxonomy
, name of the taxonomy,category
,post_tags
orcustom-taxonomy
<?php
/*
Plugin Name: Translate Taxonomy Admin Strings
Plugin URI: https://wordpress.stackexchange.com/q/71992/12615
Description: Translate specific strings in admin screens Edit Tag
Version: 0.1
Author: Rodolfo Buaiz
License: GPL v2
*/
/**
Configuration
@params_71992['context'] as defined in /wp-admin/edit-tags.php
@params_71992['replacements'] original text and translation
@params_71992['taxonomy'] name of the taxonomy (category, post_tag, custom_taxonomy)
*/
$params_71992 = array (
'context' => array (
'Taxonomy Description'
, 'Taxonomy Name'
)
, 'replacements' => array (
'Description' => 'Title'
, 'Name' => 'The Name'
)
, 'taxonomy' => 'category'
);
// Run only in Edit Tags screens
add_action( 'admin_head-edit-tags.php', 'wpse_71992_register_filter' );
function wpse_71992_register_filter()
{
add_filter( 'gettext_with_context', 'wpse_71992_translate', 10, 4 );
}
function wpse_71992_translate( $translated, $original, $context, $domain )
{
global $params_71992;
// If not our taxonomy, exit early
if( $params_71992['taxonomy'] !== $_GET['taxonomy'] )
return $translated;
// Text is not from WordPress, exit early
if ( 'default' !== $domain )
return $translated;
// Check desired contexts
if( !in_array( $context, $params_71992['context'] ) )
return $translated;
// Finally replace
return strtr( $original, $params_71992['replacements'] );
}