marcan_rcd
(Marc-Antoine)
January 15, 2016, 1:50am
1
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
Can you help me to find how achieve this ?
bencarlo
(Ben Carlo)
January 15, 2016, 9:34am
2
Hey Marc-Antoine,
Welcome to the BB forums!
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?
Ben
marcan_rcd
(Marc-Antoine)
January 15, 2016, 10:04am
3
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”
bencarlo
(Ben Carlo)
January 15, 2016, 7:09pm
4
Gotcha! Adding the functions/filters below to your functions.php
file should do the trick!
// 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
marcan_rcd
(Marc-Antoine)
January 16, 2016, 2:04am
5
Thank you, it’s perfectly working
I love your plugin !
bencarlo
(Ben Carlo)
January 18, 2016, 6:48am
6
Good to hear that it’s working and you loving the plugin! Enjoy!
Ben