Skip Navigation

[Assigned] Help for translating a parametric label

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 1 voice.

Last updated by nicolaS-3 14 hours, 52 minutes ago.

Assisted by: Minesh.

Author
Posts
#2862707

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

#2862777

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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";
    }

I see I already assisted before you with such query and here is the old ticket link for reference:
=> https://toolset.com/de/forums/topic/cant-translate-labels-in-english/page/2/#post-2551493

#2862850

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";

Is the domain correct ?

#2862857

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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 );
#2862863

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

#2863159

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2863179

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please send me FTP access details as well.

I have set the next reply to private which means only you and I have access to it.

#2863264

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The FTP/SFTP access details you shared is not working at this end.

Can you please send me working FTP/SFTP access details.

I have set the next reply to private which means only you and I have access to it.