Skip Navigation

[Resolved] Can't translate labels in English

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.

Our next available supporter will start replying to tickets in about 2.25 hours from now. Thank you for your understanding.

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 13 replies, has 2 voices.

Last updated by nicolaS-3 1 year, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2546313

Hi,
I need to translate some labels that still appear in English here and there on my pages. Some time ago you suggested me the following snippet but some of the strings are still not translated, maybe I am using the wrong domain names (wpv-.... or wp-.... ?) as I don't know all correct domain names. I tried some variations, but still not working. Pls let me have all correct Toolset domain names so that I can apply the right ones in the future, thanks.

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Cerca un post";
    }
    if($text == 'Please enter %NUM% or more characters' && $domain == 'wpv-views'){
      $translated_text = "Digita almeno %NUM% caratteri";
    }
      if($text == 'Hour' && $domain == 'wpv-cred'){
      $translated_text = "Ora";
    }
        if($text == 'Use my location' && $domain == 'wp-maps'){
      $translated_text = "Usa la mia posizione";
    }
          if($text == 'Show/Hide coordinates' && $domain == 'wp-maps'){
      $translated_text = "Mostra/Nascondi coordinate";
    }
      if($text == 'Get new password' && $domain == 'wpv-views'){
      $translated_text = "Imposta una nuova password";
    }
        if($text == 'Username or Email' && $domain == 'wpv-views'){
      $translated_text = "IDUtente oppure Email";
    }
    return $translated_text;
}, 20, 3 );

Kind regards
Nicola

#2546435

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share information what text is not get translated and on what page and share admin access details and let me review what plugins are added and from where those texts are coming from.

*** 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.

#2547237

Minesh
Supporter

Languages: English (English )

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

hidden link
Add New in Immagini field (add images)
==>
Changed the text using the gettext hook.

BTW - on this same page I have two taxonomy selects (TIpo strumento and Marca) where select_text="----SELECT---" doesn't work, why it works for fields and not for selects ?
==>
I've added the following custom JS code to your form's JS editor to add the default option:

jQuery(document).ready(function($) {
    jQuery("select[name='instrument[]']").prepend('<option value="">--- SELEZIONA ---</option>');
    jQuery("select[name='instrument[]']")[0].selectedIndex = 0;
  
   jQuery("select[name='brand[]']").prepend('<option value="">--- SELEZIONA ---</option>');
   jQuery("select[name='brand[]']")[0].selectedIndex = 0;
  
  
});

hidden link (add event)
Same address as previous + Hour/Minute in the Data inizio (start date) field
==>
The hour and Minute is translated.

The latest gettext hook is as given under:


add_filter( 'gettext', function( $translated_text, $text, $domain ) {
  
   if($domain != 'wpv-views') return $translated_text;
  
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Seleziona una band";
    }
    if($text == 'No bands can be associated to' && $domain == 'wp-cred'){
      $translated_text = "Nessuna band da associare a";
    }
   if($text == 'Enter address' && ($domain == 'toolset-maps')){
      $translated_text = "Inserisci l'indirizzo";
    }
 
  if($text == 'Show/Hide coordinates' && $domain == 'toolset-maps'){
      $translated_text = "Mostra/Nascondi le coordinate";
    }
  
 
  
    if($text == 'Add new' && ($domain == 'wp-cred' or $domain = 'wpv-views')){
      $translated_text = "Aggiungi";
    }
    if($text == 'Please enter %NUM% or more characters' && $domain == 'wpv-views'){
      $translated_text = "Digita almeno %NUM% caratteri";
    }
      if($text == 'Hour' && $domain == 'wpv-views'){
      $translated_text = "Ora";
       
    }
        if($text == 'Minute' && $domain == 'wpv-views'){
      $translated_text = "Minuti";
    }
  
  
       
   if($text == 'Use my location' && $domain == 'toolset-maps'){
      $translated_text = "Usa la mia posizione";
    }
     if($text == 'Show/Hide coordinates' && $domain == 'toolset-maps'){
      $translated_text = "Mostra/Nascondi coordinate";
    }
      if($text == 'Get new password' && $domain == 'wpv-views'){
      $translated_text = "Imposta una nuova password";
    }
        if($text == 'Username or Email' && $domain == 'wpv-views'){
      $translated_text = "IDUtente oppure Email";
    }
    return $translated_text;
}, 30, 3 );

I'm checking for "Get New Password", "Use my location" and "Show/Hide coordinates".

I'll update you when I found solution for that.

#2547339

Minesh
Supporter

Languages: English (English )

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

Can you please share FTP access details as I'll require to add the gettext hook to your theme's functions.php file.

Or maybe you can add the gettext hook I shared and move it from "Custom Code" section to your theme's functions.php file.

Does that helps? if no:
- Please share FTP access details.

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

#2548685

Minesh
Supporter

Languages: English (English )

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

Thank you for sharing FTP access details but unfortunately the shared FTP access details not working at this end.

Can you please send me working FTP access details.

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

#2548699

Try now, it should work, port 21 thanks

#2548787

Minesh
Supporter

Languages: English (English )

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

I've moved the gettext code to functions.php file:

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
  
    
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Seleziona una band";
    }
    if($text == 'No bands can be associated to' && $domain == 'wp-cred'){
      $translated_text = "Nessuna band da associare a";
    }
   if($text == 'Enter address' && ($domain == 'toolset-maps')){
      $translated_text = "Inserisci l'indirizzo";
    }
 

  
    if($text == 'Add new' && ($domain == 'wp-cred' or $domain = 'wpv-views')){
      $translated_text = "Aggiungi";
    }
    if($text == 'Please enter %NUM% or more characters' && $domain == 'wpv-views'){
      $translated_text = "Digita almeno %NUM% caratteri";
    }
      if($text == 'Hour' && $domain == 'wpv-views'){
      $translated_text = "Ora";
       
    }
        if($text == 'Minute' && $domain == 'wpv-views'){
      $translated_text = "Minuti";
    }
  
   
   if($text == 'Use my location' &&  ($domain == 'wp-cred' or $domain == 'wpv-views' or $domain == 'toolset-maps')){
      $translated_text = "Usa la mia posizione";
    }
     if($text == 'Show/Hide coordinates' && $domain == 'toolset-maps'){
      $translated_text = "Mostra/Nascondi coordinate";
    }
      if($translated_text == 'Get New Password' and   ($domain == 'wp-cred' or $domain == 'wpv-views' or $domain == 'toolset-maps')){
      $translated_text = "Imposta una nuova password";
    }
        if($text == 'Username or Email' && $domain == 'wpv-views'){
      $translated_text = "IDUtente oppure Email";
    }
    return $translated_text;
}, 10, 3 );

The only string that is not translated now is "Get New Password". I will work on that and will get back to you.

#2548837

Hi,
whatever I do now on the site gives me the following error
Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in /home/musicain/public_html/wp-content/themes/kadence/functions.php on line 80
There has been a critical error on this website. Please check your site admin email inbox for instructions.

#2548871

Minesh
Supporter

Languages: English (English )

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

I've fixed that issue. I can see everything is working.

#2550819

My issue is resolved now. Thank you!

#2550905

Hello Minesh,
Today I found other two strings which are not translated, belonging to the relationship select:
Searching...
No results found
I tried to fix the translation myself opening my functions.php but I couldn't find your snippet in it and it isn't in toolset/settings either. Where is it ?
BTW - Could I use Loco Translate instead to translate any Toolset strings ?
thanks
Regards
Nicola

#2550947

Minesh
Supporter

Languages: English (English )

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

As the ticket marked resolved the private access details is automatically removed.

Can you please share problem URL where strings is not translated 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) to your site.

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

Regarding - Loco Translate - I do not have any experience with that.

We offer WPML if you would like to consider that.
=> https://wpml.org/purchase/

Additionally, May I kindly ask you to open a new ticket with every new question you may have. This will help other users searching on the forum as well as help us to write correct problem resolution summery. Thank you for understanding.

#2551493

Minesh
Supporter

Languages: English (English )

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

I've added the following gettext hook and fix all those strings which you raised.

The code is added to your theme's functions.php file at bottom of the functions.php file:
=> /public_html/wp-content/themes/kadence/functions.php

/* Translating Text using gettext hook */

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
  
    
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Seleziona una band";
    }
    if($text == 'No bands can be associated to' && $domain == 'wp-cred'){
      $translated_text = "Nessuna band da associare a";
    }
   if($text == 'Enter address' && ($domain == 'toolset-maps')){
      $translated_text = "Inserisci l'indirizzo";
    }
 

  
    if($text == 'Add new' && ($domain == 'wp-cred' or $domain = 'wpv-views')){
      $translated_text = "Aggiungi";
    }
    if($text == 'Please enter %NUM% or more characters' && $domain == 'wpv-views'){
      $translated_text = "Digita almeno %NUM% caratteri";
    }
      if($text == 'Hour' && $domain == 'wpv-views'){
      $translated_text = "Ora";
       
    }
        if($text == 'Minute' && $domain == 'wpv-views'){
      $translated_text = "Minuti";
    }
  
  //echo "<br/>".$text."===".$translated_text."===".$domain;
  
  if($text == 'Searching...' &&  ($domain == 'wp-cred' or $domain == 'wpv-views' or $domain == 'toolset-maps')){
      $translated_text = "Ricerca in corso ...";
  }
  
  if($text == 'No results found' &&  ($domain == 'wp-cred' or $domain == 'wpv-views' or $domain == 'toolset-maps')){
      $translated_text = "Nessun risultato";
  }
	
       
   if($text == 'Use my location' &&  ($domain == 'wp-cred' or $domain == 'wpv-views' or $domain == 'toolset-maps')){
      $translated_text = "Usa la mia posizione";
    }
     if($text == 'Show/Hide coordinates' && $domain == 'toolset-maps'){
      $translated_text = "Mostra/Nascondi coordinate";
    }
      if($translated_text == 'Get New Password' and ($domain == 'wp-cred' or $domain == 'wpv-views' or $domain == 'toolset-maps')){
      $translated_text = "Imposta una nuova password";
    }
        if($text == 'Username or Email' && $domain == 'wpv-views'){
      $translated_text = "IDUtente oppure Email";
    }
    return $translated_text;
}, 10, 3 );

I kindly ask you to open a new ticket with every new question you may have. This will help other users searching on the forum as well as help us to write correct problem resolution summery. Thank you for understanding.

You can mark this ticket resolved with different message as "This ticket is resolved again"

#2554911

This ticket is resolved again, thanks