Skip Navigation

[Resolved] Translate button text

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.

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 1 month, 3 weeks ago.

Assigned support staff: Christian Cox.

Author
Posts
#2154683
Screenshot 2021-08-29 at 4.14.14 PM.png
Screenshot 2021-08-29 at 5.34.50 PM.png

Dear Sir/Madam,

I have an add post form containing file upload element, my site's default language is Traditional Chinese, please advise how I can translate the text from the button.

Best regards,

Kelvin.

#2155323

You can add the following custom code snippet and translate this text:

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