Skip Navigation

[Resolved] How to translate the "clear" button ?

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

Problem:
Translate the "Clear" button of Views filter form.
Solution:
You can translate the text with WordPress filter hook "gettext", for example, add below codes into your theme functions.php:

add_filter( 'gettext', 'clear_button_func', 20, 3 );
/**
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function clear_button_func( $translated_text, $text, $domain ) {
    if($text == 'Clear' && $domain = 'wpv-views'){
        $translated_text = "Clear Cn";
    }
    return $translated_text;
}

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

This support ticket is created 8 years, 2 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by mcjS 8 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#366688
clear-button.png

I am trying to: translate the word "clear" on a button. It appears when an user has uploaded an image on a cred form.
I try to translate it with Loco translate, but there is no string available to translate?

#366817

Dear mcjS,

You can translate the text with WordPress filter hook "gettext", for example, add below codes into your theme functions.php:

add_filter( 'gettext', 'clear_button_func', 20, 3 );
/**
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function clear_button_func( $translated_text, $text, $domain ) {
	if($text == 'Clear' && $domain = 'wpv-views'){
		$translated_text = "Clear Cn";
	}
	return $translated_text;
}

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

#367345

TNX!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.