Skip Navigation

[Resolved] Translate "upload or select image " and "ADD" tag buttons

This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

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

Last updated by IgorP708 5 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#1420019
Screenshot_128.jpg

Hi

Can't find where can I translate "upload or select image " and "ADD" tag buttons. I tried Loco translate(toolset CRED) but no luck.

#1421191

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

To translate the text "Upload or select file" of upload button you should try to add the following code to your current theme's functions.php file:

add_filter('gettext', function($translated_text, $untranslated_text, $domain){
    if($untranslated_text == 'Upload or select file' && $domain == 'wp-cred'){
        $translated_text = 'traslated text for Upload or select file goes here';
    }

     if($untranslated_text == 'Add' && $domain == 'wp-cred'){
        $translated_text = 'traslated text for add goes here';
    }
    return $translated_text;
}, 10, 3);

More help:
https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

#1421973

That did not helped unfortunately. I've tried both via Code Snippet plugin and directly add to functions.php

#1422699

Minesh
Supporter

Languages: English (English )

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

Can you please try the following code:

Add the following code to your theme's functions.php file:

add_filter( 'gettext', 'func_change_forms_upload_button_texts', 20, 3 );
function func_change_forms_upload_button_texts( $translated_text, $untranslated_text, $domain ) {
 
    if ( !is_admin() ) {
 
      if( $untranslated_text== 'Upload or select image' && $domain == 'wp-cred' ) {
             $translated_text = 'traslated text for Upload or select file goes here';
        }
 
    }
 
    return $translated_text;
}

The above code should help you now to translate the "Upload or select image" text. You should replace your translated text and for tag "Add" button I need to check on your install. Can you please share the URL where you added the form and temporary admin access details with FTP access so I can access the functions.php file.

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

#1427709

Minesh
Supporter

Languages: English (English )

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

I would like to know - the site you are building is in a single language - correct? If yes:
Can you please share wp-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.

#1430969

Minesh
Supporter

Languages: English (English )

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

Can you please check now:

I've added the following code to your theme's functions.php file:
- You can add translated text as required.

add_filter( 'gettext', 'func_change_forms_upload_button_texts', 20, 3 );
function func_change_forms_upload_button_texts( $translated_text, $untranslated_text, $domain ) {
  
    if ( !is_admin() ) {
  
      if( $untranslated_text== 'Upload or select image' && $domain == 'wp-cred' ) {
             $translated_text = 'Добавить изображение';
       }
	   if( $untranslated_text== 'Image for this field' && $domain == 'wpv-views' ) {
             $translated_text = 'translate here';
       }
	   
	   if( $untranslated_text== 'Add image' && $domain == 'wpv-views' ) {
             $translated_text = 'Add image - translate here';
       }
 
  
    }
  
    return $translated_text;
}

To translate the Add button text for post tag, you can add/change the button text by editing your Toolset form:
=> hidden link
Navigate to section 'Сообщения' and find the field "Добав. термин систематики" and change the "Add" text to your required text.

#1437891
Screenshot_142.jpg

Thank you for your help. Code works fine.

One more thing. When image added there is phrase a "Replace Image". This need to be translated as well

#1437903

Minesh
Supporter

Languages: English (English )

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

Glad to know that code I shared works as expected.

You can add the following if conditions to the hook "gettext" I shared before:
=> https://toolset.com/forums/topic/translate-upload-or-select-image-and-add-tag-buttons/#post-1430969

if( $untranslated_text== 'Replace image' && $domain == 'wpv-views' ) {
             $translated_text = 'Replace image - translate here';
}
if( $untranslated_text== 'Replace image' && $domain == 'wp-cred' ) {
             $translated_text = 'Replace image - translate here';
}
#1437949

My issue is resolved now. Thank you!