Skip Navigation

[Resolved] Cannot translate cred-form-cancel and cred-relationship-role

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

Problem:

Translate cred-form-cancel and cred-relationship-role shortcodes.

Solution:

For the cancel link, you can customize the text and message with shortcode attribute: "label" and "message", for example:

https://toolset.com/forums/topic/cannot-translate-cred-form-cancel-and-cred-relationship-role/#post-1689705

For the role cred-relationship-role shortcode, you can translate the texts with WP gettext filter hook, for example:

https://toolset.com/forums/topic/cannot-translate-cred-form-cancel-and-cred-relationship-role/#post-1690857

Relevant Documentation:

http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

This support ticket is created 4 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
- 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)

This topic contains 4 replies, has 2 voices.

Last updated by nicolaS-3 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1689171

Hi !
I have 2 relationship forms where I still see cred-form-cancel and cred-relationship-role in English, no way I can translate them into Italian, any clue ? I don't use WPML
Thanks
Regards
Nicola

#1689705

Dear Nicola,

For the cancel link, you can customize the text and message with shortcode attribute: "label" and "message", for example:

[cred-form-cancel field='cancel' label='my cacel link text' message="my message!"]

For the role cred-relationship-role shortcode, you can translate the texts with WP gettext filter hook, for example, add below codes into your theme file "functions.php":

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Custom text here";
    }
    return $translated_text;
}, 20, 3 );

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

#1690099

Hi Luo,
Cancel works perfectly thanks. The second filter works too but there are two texts to be translated, one before the dropdown opens and the other one when it's opened. I modified your filter to accomodate both labels,

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Seleziona";
    }
	if($text == 'Please enter 3 or more characters' && $domain == 'wp-cred'){
      $translated_text = "Digita almeno 3 caratteri";
    }
    return $translated_text;
}, 20, 3 );

the first one is translated, the second doesn't ! Should I create a separate filter for that ?
thanks
Regards
Nicola

#1690857

Please try to modify you PHP codes as below, and test again:

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "Seleziona";
    }
    if($text == 'Please enter %NUM% or more characters' && $domain == 'wpv-views'){
      $translated_text = "Digita almeno %NUM% caratteri";
    }
    return $translated_text;
}, 20, 3 );
#1691031

My issue is resolved now. Thank you!