[Support request] Unable to translate comment section fields

Home Forums Support [Support request] Unable to translate comment section fields

Home Forums Support Unable to translate comment section fields

  • This topic has 5 replies, 2 voices, and was last updated 2 months ago by Elvin.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2014122
    Karel

    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?

    #2016557
    Elvin
    Staff
    Customer Support

    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

    A wise man once said:
    "Have you cleared your cache?"

    #2018312
    Karel

    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

    #2018766
    Elvin
    Staff
    Customer 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. 🙂

    A wise man once said:
    "Have you cleared your cache?"

    #2019323
    Karel

    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.

    #2020585
    Elvin
    Staff
    Customer Support

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

    A wise man once said:
    "Have you cleared your cache?"

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.