Translating comment form

Hi,

How can I translate “Reply” to “Vastaa”? (see attachment)

I have translated the string with poedit but it doesn´t work…

I´m also using this in my functions.php to translate comments and it works. Do I need to add something to this code to translate the “Reply” also?

function comment_reform ($arg) {
$arg[‘title_reply’] = __(‘Jätä Kommentti’);
return $arg;
}
add_filter(‘comment_form_defaults’,‘comment_reform’);

add_filter(‘gettext’, ‘x_translate_text’ , 20, 3);
function x_translate_text ( $translated_text, $text, $domain ) {

$translation = array (
‘Submit’ => ‘Lähetä’,
);

if( isset( $translation[$text] ) ) {
return $translation[$text];
}

return $translated_text;

}

Hey @ukic,

Please try this code in the functions.php of the child theme:

// Translate Strings
add_filter( 'gettext', 'translate_x_strings', 20, 3 );

function translate_x_strings( $translated_text, $text, $domain ) {

        switch ( $translated_text ) {

            case 'Reply' :

                $translated_text = __( 'Jätä Kommentti', '__x__' );
                break;

            case 'Submit' :

                $translated_text = __( 'Lähetä', '__x__' );
                break;
        }

    return $translated_text;
}

Hope this helps.

Hi,

This didn´t work.

-Timo

Hi Timo,

Please update the code shared by Jade to this:

// Translate Strings
add_filter( 'gettext', 'translate_x_strings', 20, 3 );

function translate_x_strings( $translated_text, $text, $domain ) {

        switch ( $translated_text ) {

            case 'Reply' :

                $translated_text = __( 'Jätä Kommentti', '__x__' );
                break;

            case 'Submit' :

                $translated_text = __( 'Lähetä', '__x__' );
                break;
            case 'Reply <span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon-s="&#xf3e5;"></i></span>' :

                $translated_text = __( 'Jätä Kommentti <span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon-s="&#xf3e5;"></i></span>', '__x__' );
                break;

        }

    return $translated_text;
}


Hope this helps.

Hi,

This worked thank you!

One more thing. I would like to change the hover texts “Please fill out this field.” and “This is a required field” in comments.

What I need to add to the code to translate these also?

-Timo

Hey Timo,

Regretfully, those could not be translated as they are powered by Javascript. I’ll submit this to our issue tracker so our development team could decide the best way to deal with this limitation.

Thanks.

Hi @ukic,

I just wanted to chime in here and let you know that the strings you’re referring to are just part of your browser. We set a required attribute on the form inputs telling the browser that a value must be present before the form can be submitted. Those messages you’re seeing are not actually javascript but from your browser itself. This means they will be shown in the language of the end user’s operating system.

Also, the reason that you couldn’t translate “Reply” with poedit is because it is part of WordPress core, not the theme. We use the WordPress function to output a comment form and add styling to it, so the actual markup can be translated by installing a WordPress translation.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.