Hello,
I am trying to translate the string/message appearing in a relationship form when there are no available selections
if ( $text === 'No XXX can be associated to' && $domain === 'wp-cred' ) {
$translated_text = "Nessuna XXX da associare a";
where XXX is a paramenter depending on which custom post is used for creating the relationship.
Could you please let me know how to translate this label ?
thanks
Nicola
Hello. Thank you for contacting the Toolset support.
You will have to add your parent/child post type slug instead of that dynamic parameter. There is no way to get dynamic parameter so you will have to check for full string.
For example - the post type slug is 'book' then - you need to add something like as follows:
if($text == 'No book can be associated to' && $domain == 'wp-cred'){
$translated_text = "Nessuna band da associare a";
}
If above does not work then try following:
if($text == 'No book can be associated to' && $domain == 'wp-cred'){
$translated_text = "Nessuna books da associare a";
}
Hello Minesh,
Yes, you helped me long time ago for the translations, this one is the only one still not working. Understanding it's not parametric I just duplicated the messages appearing in the form dropdowns box when no options are available, but it seems not to be working either. Is this ok ?
if ( $text === 'No band can be associated to' && $domain === 'wp-cred' ) {
$translated_text = "Nessuna band da associare a";
}
if ( $text === 'No profilo can be associated to' && $domain === 'wp-cred' ) {
$translated_text = "Nessun profilo da associare a";
You can add print_r() the text to see what text is comding:
If its using while AJAX then you need to open network tab of the browser and add the print_r() to your code and add that code to your current theme's functions.php file. I hope you are using gettext filter hook.
- https://developer.wordpress.org/reference/hooks/gettext/
For example:
- add the following code to your current theme's functions.php file and then try to access the field where you see the text and open the network tab and see what text shows with the network tab request for $text.
add_filter( 'gettext', function( $translated_text, $text, $domain ) {
echo "<pre>";
print_r($text);
exit;
if ( $text === 'No band can be associated to' && $domain === 'wp-cred' ) {
$translated_text = "Nessuna band da associare a";
}
if ( $text === 'No profilo can be associated to' && $domain === 'wp-cred' ) {
$translated_text = "Nessun profilo da associare a";
{
return $translated_text;
}, 10, 3 );
Minesh,
I added the filter to the functions.php but the site stopped working, I had to remove it. Sorry but I don't know about hooks. Please let me know, thanks
Can you please share problem URL where you want to translate the string where you added the form as well as admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.