[resolved] How to translate "Comments Off" (9 posts)

  1. S.K
    Posted 8 years ago #

    When I turn comments off for a post which has no comments yet, I get the text "Comments Off" on the main blog page under the particular entry. But this term (Comments Off) doesn't figure in the latest Pot file and I also find that that term doesn't have __() or _e() function in the file comments-template.php.

    I have a blog in Tamil (ta_IN) and I want that term to be translated.

    Could someone kindly tell me how to go about it.

    Thanks in advance.

  2. That text is most likely part of your theme. Look in your theme and change it there.

  3. S.K
    Posted 8 years ago #

    I checked up with all the theme files but couldn't find the string anywhere there. I confirmed that it is picked up only from line No.317 of the file "wp-includes/comments-template.php" since whatever change I make to the text "Comments Off" (No Comments, Comments None, BlahBlah, etc) over there appear on my blog page. I even tried to insert __() etc but it returns a syntax error message - my lack of knowledge of php is the reason.

    Kindly help.



  4. Andrew Ozz
    WordPress Dev
    Posted 8 years ago #

    Look for the function comments_popup_link in your index.php, page.php or comments.php and change the strings according to this:

  5. S.K
    Posted 8 years ago #

    Thank you very much Azaozz.

    Yes, as you mentioned the hack hides the link to comments whenever comments are disabled for a post.

    But I discovered another problem:

    It is mentioned in the codex page linked by you as follows:

    Displays a link to the comments popup window if comments_popup_script() is used, otherwise it displays a normal link to comments.

    Now in my blog, in the header.php file, the comments_popup_script is put off as per the following line found there:

    <?php //comments_popup_script(); // off by default ?>
    Also, the comments are shown inline and not as a popup.

    In that case why is the popup_link (from the comments-template) is used? It beats me.

    How else to disable the comments_popup_link?

    Kindly help.


    I have this line at the top of the index.php of my theme:


  6. Andrew Ozz
    WordPress Dev
    Posted 8 years ago #

    The comments_popup_script() opens a pop-up window when you click on a comments_popup_link() link. As your comments are inline, you don't need to use comments_popup_link() to display the number of comments for a post, use the comments_number() instead.

    Search all *.php files in your theme and change comments_popup_link() to comments_number(), translating the strings. More info here:

    Also look for something like
    `<?php else : // comments are closed ?>
    <!-- If comments are closed. -->
    <p class="nocomments">Comments are closed.</p>`

    shortly after the end of the comments loop - after endforeach;

    Hope that helps :)

  7. S.K
    Posted 8 years ago #

    Thanks Azaozz.

    It worked. But the link to the comments are replaced by mere text.

    Please help.


  8. Andrew Ozz
    WordPress Dev
    Posted 8 years ago #

    I see what you mean... Why don't you try the example from comments_popup_link() page:

    <?php if ( comments_open() ) : ?>
    comments_popup_link( 'No comments yet', '1 comment',
    '% comments so far', 'comments-link', ''); ?>
    <?php endif; ?>

    leaving the last string empty (as above). Or even just the comments_popup_link() part, without the "if" "endif" lines.

  9. S.K
    Posted 8 years ago #

    Thanks a Zillion, Azaozz!

    It worked and I have inserted a message of my choice between the '' and translated the text to my locale also!

    Very kind of you.


Topic Closed

This topic has been closed to new replies.

About this Topic