I hope the theme authors read this.
In the meantime either add it manually and keep a note
or add this to your functions file
//This function changes the text wherever it is quoted
function change_translate_text( $translated_text ) {
if ( $translated_text == 'old text' ) {
$translated_text = 'new text';
}
return $translated_text;
}
add_filter( 'gettext', 'change_translate_text', 20 );
just put the old and new words to change ‘old test’ and ‘new text’
Functions files and child themes – explained !
Hello Robin,
thanks for quick response.
I tried to add manually into .po file, but it doesnt work I dont know why…
#~ msgid “ERROR: Your topic needs a title.”
#~ msgstr “CHYBA: Vaše téma musí mít název.”
Then I tried your way, function file, but there seems to be error in your code. It says:
Parse error: syntax error, unexpected ‘:’ in /data/web/virtuals/82697/virtual/www/domains/investplanet.cz/wp-content/themes/sahifa/functions.php on line 139
I changed syntax and the code is ok, but nothing happen on the page.
//This function changes the text wherever it is quoted
function change_translate_text( $translated_text ) {
if ( $translated_text == “ERROR: Your topic needs a title.” ) {
$translated_text = “CHYBA: Vaše téma musí mít název.”;
}
return $translated_text;
}
add_filter( ‘gettext’, ‘change_translate_text’, 20 );
?>
I just looked and it’s actually in the code as
<strong>ERROR</strong>: Your topic needs a title.
and the translate works on exact !
which might explain why it didn’t work in the pot
you can try it as one phrase, and if that doesn’t work, then make it two
ie
//This function changes the text wherever it is quoted
function change_translate_text( $translated_text ) {
if ( $translated_text == ‘ERROR:’ ) {
$translated_text = ‘CHYBA:’;
}
if ( $translated_text == ‘Your topic needs a title.’ ) {
$translated_text = ‘Vaše téma musí mít název.’;
}
return $translated_text;
}
add_filter( ‘gettext’, ‘change_translate_text’, 20 );
The same is probably true of the POT file, so you try all that there first !
Am I right that I should put this code into functions.php file in my theme right?
Im still getting english version.
yes in your functions file !
if it still doesn’t work, come back and when I get a moment I’ll try it in my test site
Im doing everything exactly according to your advice, but it still doesnt work. If you have a minute and take a look you will be the best.
Thanks
the following works
//This function changes the text wherever it is quoted
function change_translate_text( $translated_text ) {
if ( $translated_text == '<strong>ERROR</strong>: Your topic needs a title.' ) {
$translated_text = '<strong>CHYBA</strong>: Vaše téma musí mít název.';
}
return $translated_text;
}
add_filter( 'gettext', 'change_translate_text', 20 );
but equally well, the line is in the pot on line 3727 as
Line 3727: msgid "<strong>ERROR</strong>: Your topic needs a title."
so you could just use then normal translate !