Archived topic
Unable to change post comment section language from English to Spanish
5 replies · Started by Alfonso on October 13, 2020
Hi,
I am experiencing several issues while working with the Generatepress theme and the Elementor page builder. I want to change post's comment section language from English to Spanish. Actually, I want to change "LEAVE A COMMENT" to be "¿QUE
PIENSAS? .
And also cannot change the designs in the comment sections. when I'm going to edit the comment section design via Elementor, It is showing "The Theme Comments skin uses the currently active theme comments design and layout to display the comment form and comments". From there, I haven't any option to change comment skin. Please help me to resolve this two issues.
Thank you.
Hi,
For translating the "Leave a comment" text, you can try this PHP snippet:
add_filter( 'gettext', function( $text ) {
if ( 'Leave a comment' === $text ) {
return 'Your new text';
}
return $text;
} );
Here's how to add PHP - https://docs.generatepress.com/article/adding-php/
For comment form styling, you'll have to resort to custom CSS.
Hi,
Thank you for your support. This was not worked for me,
But below one was worked,
add_filter( 'generate_leave_comment','tu_custom_leave_comment' );
function tu_custom_leave_comment() {
return '¿QUE PIENSAS?';
}
Oh yeah I forgot to mention you have to change the "Your new text" string to the text you want.
I'm glad its working for you now. :)
Hi,
I also need to change comment sections "thoughts on" words to Spanish. (located at the top of the comments. This shows how many comments I have)
I have used below code. But not worked for me. Could you please check and give me a solution for it.
add_filter( 'gettext', function( $text ) {
if ( 'thoughts on' === $text ) {
return 'comentarios sobre';
}
return $text;
} );
Thanks
You can try this out.
add_filter( 'generate_comment_form_title', function(){
return sprintf(
esc_html(
/* translators: 1: number of comments, 2: post title */
_nx(
'%1$s comentario sobre “%2$s”',
'%1$s comentarios sobre “%2$s”',
$comments_number,
'comments title',
'generatepress'
)
),
number_format_i18n( $comments_number ),
get_the_title()
);
});