Change default translation permanently

Hi,

I want to change a translation for the form module of bb plugin without edit p0 each time an update arrive.

I finded some help here : http://forum.wpbeaverbuilder.com/support/q/override-existing-plugin-translation/

But i don’t find how to apply this correctly !

I search the theme text domain and apply this code in the functions.php of my child theme :

add_filter( 'gettext', 'theme_change_fl-form-field', 20, 3 );
/**
 * Change comment form default field names.
 *
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function theme_change_fl_form_field( $translated_text, $text, $domain ) {

    if ( is_singular() ) {

        switch ( $translated_text ) {

            case 'Name' :

                $translated_text = __( 'Votre prénom', 'fl-automator' );
                break;

            case 'Email' :

                $translated_text = __( 'Votre email', 'fl-automator' );
                break;
        }

    }

    return $translated_text;
}

This code is not working :frowning:

Can you help me to find how achieve this ?

Hey Marc-Antoine,

Welcome to the BB forums! :slight_smile:

Before I dig deeper in to this, I’d just like to know why you’d like to change the translation? Is ours incorrect? If that’s the case, we can have it fixed for you. Or do you simply want to use another term? :slight_smile:

Ben

Thank you !

Your translation is correct (even if “email” is more used than “courriel” in french) but i want personnalize the terms : if i translate in english : “Your email” instead of “Email” ans “Your First name” instead of “Name”

Gotcha! Adding the functions/filters below to your functions.php file should do the trick! :slight_smile:

// Translate the word Email Address
function my_text_translations( $translated, $text, $domain ) {
  switch ( $translated ) {
    case 'Email Address' :
      $translated = __( 'Votre email', 'fl-builder' );
      break;
  }
  return $translated;
}
add_filter( 'gettext', 'my_text_translations', 20, 3 );

// Translate the word Name on the Subscribe form module
function my_text_with_context_translations( $translated, $text, $context, $domain ) {
  if ( 'fl-builder' == $domain ) {
    if ( 'Name' == $text && 'First and last name.' == $context ) {
      $translated = 'Votre prénom'; 
    }
  }
  return $translated;
}
add_filter( 'gettext_with_context', 'my_text_with_context_translations', 10, 4 );

Ben

Thank you, it’s perfectly working :slight_smile:

I love your plugin !

Good to hear that it’s working and you loving the plugin! :slight_smile: Enjoy!

Ben