Skip Navigation

[Resolved] Translate ‘Upload or Select File’ Button w/o WPML

This thread is resolved. Here is a description of the problem and solution.

Problem:
Translate 'Upload or Select File' Button w/o WPML

Solution:
You can use the WordPress function gettext() to translate the Upload file button.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/translate-upload-or-select-file-button-w-o-wpml/#post-1339727

Relevant Documentation:
=> https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

This support ticket is created 5 years, 4 months 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 6 replies, has 3 voices.

Last updated by claudioM-3 5 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1339279
translation for button and drop down.jpg

Tell us what you are trying to do? This is a single language site (German), no budget for a translation plugin

Is there any documentation that you are following? https://toolset.com/forums/topic/how-can-i-translate-cred-frontendform-buttons-z-b-upload-or-select-file/

Is there a similar example that we can see? same as link above. The button needs to read instead: 'Datei wählen oder hochladen'

What is the link to your site? hidden link

2) also the drop down of the Select custom field (Zielgruppe) says '-- Not Set --' which I need to read '-- auswählen --'

#1339407

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know are you using WPML, if Yes, then you can translate the string using String Translation plugin.

Please check the following image:
=> https://toolset.com/wp-content/uploads/2016/11/wpml-string-name-attribute.png

From the string translation page, you should select the "wp-cred" as the domain from "All Domain" dropdown and search for the string "Upload or select file" and then translate into all your required languages.

The same steps apply to search the string "Not Set".

#1339709

Hi Minseh,
The client has no budget for the WPML plug-in license in this project. I need the PHP code to translate these items. Also is there an easy way for me to find out what the code is myself in the future, as I may encounter other items on the website related to Toolset that need translating?

#1339727

Minesh
Supporter

Languages: English (English )

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

What if you 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 test for Upload or select file goes here';
	}
	return $translated_text;
}, 10, 3);
 

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

#1339737

Thanks Minesh, that's it!

#1339739

My issue is resolved now. Thank you!

#1580093

Hi, how can I set this filter to work only in a specific language?