• Resolved emliron

    (@emliron)


    Hello,


    I’m using WPML on my site. The emails defined in the plugin are not translated.

    I’ve redefined the bsp_topic_message function in functions_email.php, replacing the lines :

    88: $message = (!empty($bsp_style_settings_email[$type]) ? $bsp_style_settings_email[$type] : $message) ;

    with 88: $message = (!empty($bsp_style_settings_email[$type]) ? __e($bsp_style_settings_email[$type],’bbp-style-pack’) : $message) ;

    and line :

    102 : $message = str_replace( “\r”, ‘<br>’, $message );

    by the lines :

    $message = str_replace( “\r”, ‘<br>’, $message );


    $message = str_replace( “\r”, ‘<br>’, $message );

    $message = str_replace( “\n”, ‘<br>’, $message );

    This works, but it would be simpler if it were modified in the plugin.

    The same would have to be done for bsp_reply_message.

    Another way would be to redefine the $bsp_style_settings_email variable to take account of translations.

    Once this change was made, I was able to translate the templates using WPML’s string translation.

    Best regards

    Emmanuel

    ?

Viewing 15 replies - 1 through 15 (of 35 total)
  • Plugin Author Robin W

    (@robin-w)

    Thanks, I’ll take a look at that in the next couple of days

    Plugin Author Robin W

    (@robin-w)

    ok, IO’ve taken a look

    can you just clarify this change:

    and line :

    102 : $message = str_replace( “\r”, ‘<br>’, $message );

    by the lines :

    $message = str_replace( “\r”, ‘<br>’, $message );

    $message = str_replace( “\r”, ‘<br>’, $message );

    $message = str_replace( “\n”, ‘<br>’, $message );

    do you mean you’ve just added a line

    $message = str_replace( “\n”, ‘<br>’, $message );

    or what exactly is the change?

    Thread Starter emliron

    (@emliron)

    I think the WPML interface writes ‘/n’ instead of ‘/r’ or ‘/r/n’.

    Because of this, the initial line is not enough to create line breaks. At least, that’s the problem I found, and I corrected it this way.

    • This reply was modified 10 months, 2 weeks ago by emliron.
    Plugin Author Robin W

    (@robin-w)

    thanks, I have just released 5.7.9 which has these changes in it – please confirm that it all works

    Thread Starter emliron

    (@emliron)

    Thanks for the update.
    Since you updated, the __e() function is undefined, I don’t know why and it’s probably nothing to do with that. I don’t understand.

    I replaced __e(…) with translate(…) in my initial script and in the plugin, and it works.

    You didn’t add the line:
    $message = str_replace( “\r\n”, ‘<br>’, $message );

    In the native version (the backend), line breaks contain ‘\r\n’. So the conversion, without this line, adds two line breaks.
    In the text translated by WPML, there is only ‘\n’, hence the interest in the other lines.
    This is what I’m seeing in the messages sent. In the English version, without this line, there are double line breaks.

    Thread Starter emliron

    (@emliron)

    Sorry, I’ve realised my mistake: the correct syntax is __( $text, $domain), not __e($text, $domain)!
    I’ve corrected it and it works…

    Plugin Author Robin W

    (@robin-w)

    thanks – the /r/n as a single line is not mentioned above, which I asked for clarification on

    can you state what exact lines you want there and in what order?

    Thread Starter emliron

    (@emliron)

    The “/n”, “/r”, “/r/n” should be replaced by a single “<br>”.
    I propose to replace:

    $message = str_replace( “\r”, ‘<br>’, $message );

    by the lines :

    $message = str_replace( “\r\n”, ‘<br>’, $message );
    $message = str_replace( “\r”, ‘<br>’, $message );
    $message = str_replace( “\n”, ‘<br>’, $message );

    Plugin Author Robin W

    (@robin-w)

    Thanks, I’ll add and release later today

    Thread Starter emliron

    (@emliron)

    Thanks for the update. It works “almost”. You forgot a \ in the lines:
    $message = str_replace( “\r\n”, ‘<br>’, $message );
    before the r. If not, that’s great!

    Thread Starter emliron

    (@emliron)

    Hi Robin,
    I have another request!. For testing, I used subscriptions management. It works very well from a forum, but not at all from a user: when you validate with the button, it seems to run but there are no changes. I tested on two sites, with the same error (I’m using the Enfold theme).

    Plugin Author Robin W

    (@robin-w)

    sorry, I cannot immediately replicate this – can you give me exact steps to recreate.

    so from dashboard>users>a user> subscriptions what are you ticking, selecting/pressing in detail please?

    Thread Starter emliron

    (@emliron)

    I tick the chosen forum, select the option (subscribe or unsubscribe) and validate. And nothing changes! ( (I also check in the forum subscriptions section)

    Plugin Author Robin W

    (@robin-w)

    ok, I cannot replicate this on my test site.

    Plugin Author Robin W

    (@robin-w)

    it could be a theme or plugin issue

            Themes
    
            As a test switch to a default theme such as twentytwenty, and see if this fixes.
    
            Plugins
    
            If that doesn't work, also deactivate all plugins apart from bbpress and see if this fixes.  if it does, re-enable one at a time to see which is causing the error.
    
            If you cannot do this to your site (say because it is live) then use the 'troubleshooting' features of this plugin to let you test without affecting other users
    
            https://en-gb.www.ads-software.com/plugins/health-check/
    
    
            Then come back
Viewing 15 replies - 1 through 15 (of 35 total)
  • The topic ‘E-mail translation’ is closed to new replies.