Translating the comment section


(Dan Eriksson) #1

So, I’ve finally decided to get rid of Disqus and use Discourse also to display comments on my blog.

I’ve been searching this part of the forum, but I can’t really find out how to translate the text that’s displayed under my blog posts. For example “Notable replies” and “Continue the discussion at…”

Is there anyone who can explain to me in a pedagogic way? :slight_smile:

Thanks in advance.


(Simon Cossar) #2

I’m working right now to make it all the user facing text configurable from the admin section. I think that can be ready soon - later this week - if it gets approval. There’s also an issue on the plugin’s github page about it: Is it possible to translate the messages? · Issue #251 · discourse/wp-discourse · GitHub

For now you can do something like this:

add_filter( 'gettext', 'change_notable_replies_text', 20, 3 );
function change_notable_replies_text( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
    // The text content you want to change.
    case 'Notable Replies' : 
            // What you want to change that text to.
            $translated_text = __( 'Our Favourite Replies', 'wp-discourse' );
        break;
    }

    return $translated_text;
}

I can add more detail if this isn’t clear. See this for more detail about the gettext hook:
https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext