Site logo

Archived topic

Unable to translate comment section fields

5 replies · Started by Karel on November 22, 2021

Viewing posts 1–6 of 6

Hi,

I’m trying to have the fields in the comment section ("leave a comment", "Name", "Post comments") in Dutch.
I can't figure out why it doesn't work.

I downloaded both generatepress free and GP Premium theme translations with a filter on “comment” on WordPress.org and uploaded them to the wp-content/languages/themes folder. No success.

I verified that the concerned words and text are present in the .po files. They are present in the free version .po
I tried changing the name from wp-themes-generatepress-nl.po to wp-themes-generatepress-nl_BE.po (my site language is nl_BE)
I tried the same using the .mo versions
I purged cache
To verify, I hard changed the “Leave a comment” string using a filter. That works, but it is not a solution for the other fields. And I figure it should work the proper way, using the available translation.

Do you have an idea what could be the cause?

Hi Karel,

The theme filter's the comment form's default with this:
https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/inc/structure/comments.php#L155

You may have to remove this filter hook or override it with a filter of higher priority value.

Removing example PHP snippet:

function remove_theme_filters(){ 
	add_filter( 'comment_form_default_fields', 'generate_filter_comment_fields' );
}
add_action( 'after_setup_theme', 'remove_theme_filters' );

As for the field labels, here's the code responsible:
https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/inc/structure/comments.php#L163-L192

Here's a sample filter to modify it:
https://generatepress.com/forums/topic/como-cambio-el-idioma-en-la-seccion-comentarios-del-blog/#post-1699721

Hi,

Thanks for your answer. So if I understand it right, GP (recent versions) filters out the default comment field structure.
That also seems to mean that the GP and GP premium translation files on wordpress.org are useless for that part, am I right? (Some support topics still refer to that as a solution).

I don't want to edit the theme itself, and neither "filter out the filter" as there was surely an intention to modify the default structure.

So, using a filter to only change the text strings is probably the best remaining option, as in this example you mentioned:
https://generatepress.com/forums/topic/como-cambio-el-idioma-en-la-seccion-comentarios-del-blog/#post-1699721

Then I have two remaining questions:
-how do I disable the URL field (the website question)
-is it possible to modify the default window size of the comment window?

Thanks again for your support

That also seems to mean that the GP and GP premium translation files on wordpress.org are useless for that part, am I right? (Some support topics still refer to that as a solution).

Not entirely useless. Some partially works but may need a bit of updating.

So, using a filter to only change the text strings is probably the best remaining option, as in this example you mentioned:
https://generatepress.com/forums/topic/como-cambio-el-idioma-en-la-seccion-comentarios-del-blog/#post-1699721

Either that or use translation plugins like WPML and use the textdomain generatepress for text translations. Tom made the text strings translatable. :)

-how do I disable the URL field (the website question)

On the same filter, you'll have to do unset($fields['url']);. Reference - https://docs.generatepress.com/article/remove-e-mail-and-url-field-from-comment-form/

-is it possible to modify the default window size of the comment window?

That can be done with CSS. If you can provide a mockup image of how you want it to be laid out, we can help you with the CSS write-up. :)

Hi, thanks, that is clear!

For the question
-is it possible to modify the default window size of the comment window?

I actually wanted to set the default height of the textarea to the same height as the other input field (but still resizable), and I found that I can use

.comment-form-comment textarea {
height: 46px
}

to achieve this.

So all good.

Thank you for letting us know. I believe you've fully sorted it out already? Let us know if you need further help. :D

This archived topic is closed to new replies.