Template Guides

Text & Translations

Every word Comments shows on your site goes through Craft's translations in the comments category. That covers the thread's buttons, headings and placeholders, the messages it shows after someone posts, votes or reports, and the errors the server sends back. The thread is drawn in the browser, but its wording still comes from your translations, because the thread's data carries every label already translated into the site's language. So you change the wording the same way you would for any Craft plugin, per site language and without any JavaScript.

Changing the Wording

Suppose you want “Comment submitted for moderation.” to say something friendlier, and the empty thread to say something other than “Be the first to comment.” Create translations/en/comments.php in your project's root folder, next to templates/, and return the messages you want to change, keyed by the original English text:

<?php

return [
    'Comment submitted for moderation.' => 'Thanks! A moderator will check your comment soon.',
    'Be the first to comment.' => 'Nobody has said anything yet.',
];

The next comment posted that waits for a moderator shows “Thanks! A moderator will check your comment soon.”, and a thread with no comments shows “Nobody has said anything yet.” Everything you leave out keeps its usual wording.

Copy each key exactly as it appears in vendor/verbb/comments/src/translations/en/comments.php, including its punctuation and curly apostrophes, such as Delete this comment? This can’t be undone. Keep any placeholder in braces, such as {name} or {count}, because the thread fills it in.

The folder is named after the site's language. en covers every English site, such as en-US and en-GB, and a file in a more specific folder, such as translations/en-GB/comments.php, wins for that language. For a site in another language, use its folder, such as translations/de/comments.php, and your messages replace Comments' own translations for that language. On a multi-site install, each site's thread uses its own site's language, so a German site gets the German wording on the same page template.

What the Translations Reach

The thread's own wording is the largest part, listed in The Thread's Labels below. Alongside it, the same file changes:

  • What craft.comments.render() puts in the page before the thread is drawn. The heading is {count, plural, =1{# comment} other{# comments}}, an ICU plural message, and visitors without JavaScript see Turn on JavaScript to read and post comments.
  • The messages the thread shows after an action, such as Comment posted., Comment deleted. and Report withdrawn.
  • The errors the server sends back, such as This field can’t be filled in here. beside a custom field, which also reach a headless front end as each error's message.

A few things have their own place instead:

  • Custom field labels come from the Comment field layout, and go through the site category, so translate them in translations/<language>/site.php as you would any field label.
  • Editor's own controls, with rich authoring on, such as its toolbar, link and mention search and its GIF search, go through Editor's editor category, so translate them in translations/<language>/editor.php, keyed by the English text in vendor/verbb/editor/src/translations/en/editor.php.
  • Badge labels and Report Reasons are settings, under Comments → Settings → Appearance and Interactions.
  • Emails are edited under Utilities → System Messages, as described in Customising Emails.

Checking a Translation

After saving the file, open a page with comments in a private window. The heading above the thread and the Join the conversation card both come from your translations, so a change to either shows straight away. A message that only appears after an action, such as the moderation one above, needs that action, so post a test comment on an entry with pre-moderation on.

If nothing changes, check the key against Comments' own file character by character. A straight apostrophe where Comments uses a curly one (’) is the most common reason a translation doesn't match.

The heading render() outputs is the one search engines and visitors without JavaScript see, so it's worth checking in the page's source as well. This changes it to count replies:

<?php

return [
    '{count, plural, =1{# comment} other{# comments}}' => '{count, plural, =1{# reply} other{# replies}}',
];

For an entry with three comments, the mount point {{ craft.comments.render(entry) }} outputs then reads like this:

<section id="comments-109-1" class="comments comments--reserve-2" aria-labelledby="comments-109-1-heading" data-comments-root …>
    <h2 id="comments-109-1-heading" class="comments__heading">3 replies</h2>
    <noscript><p class="comments__noscript">Turn on JavaScript to read and post comments.</p></noscript>
</section>

Wording in a JavaScript App

A front end that draws the thread with Comments' JavaScript packages can also pass its own labels, keyed by the names in the table below, such as { beFirst: 'Nobody has said anything yet.' }. Those win over the translated labels the thread's data carries, which is useful for a single page or an app that manages its own text. The package docs (opens new window) explain where labels goes for the bundled script, the web component and the React and Vue components. For anything that should change on every page, prefer a translation file, because it also reaches the server's messages and the page's heading.

The Thread's Labels

These are the labels the thread's data carries, with the English text that's also their key in your translation file. The name is what JavaScript labels use, and the package docs (opens new window) list a few more that only the renderer uses, which can only be changed that way.

NameEnglish Text
commentCountOne1 comment
commentCountOther{count} comments
showCommentsShow comments
showCommentsCountShow comments ({count})
loadingLoading comments…
loadMoreLoad more comments
emptyNo comments yet.
beFirstBe the first to comment.
closedComments are closed.
sortLabelSort comments
sortNewestNewest
sortOldestOldest
sortTopTop
replyReply
replyToReply to {name}…
replyingToReplying to {name}
cancelReplyCancel reply
cancelCancel
postPost
postingPosting…
saveSave comment
editEdit
editedEdited
deleteDelete
deleteConfirmDelete this comment? This can’t be undone.
likeLike
likesLikes
upvoteUpvote
downvoteDownvote
scoreScore
reportReport…
reportTitleReport this comment
reportReasonWhat’s wrong with it?
reportDetailsAnything else?
reportDetailsHintOptional. Only moderators see this.
sendReportSend report
reportSentThanks for reporting this. A moderator will take a look.
reportWithdrawnReport withdrawn.
closeClose
moreActionsMore actions
copyLinkCopy link
linkCopiedLink copied.
showRepliesShow replies
hideRepliesHide replies
loadMoreRepliesLoad more replies
guestGuest
commentByComment by {name}
unavailableComment unavailable.
awaitingApprovalWaiting for approval. Only you can see this until a moderator approves it.
editorPlaceholderAdd to the conversation…
editPlaceholderEdit your comment…
yourCommentYour comment
writeSomethingFirstWrite something first.
tooLongToo long by {count} characters
charactersLeft{count} characters left
characterCount{count} of {limit} characters
draftSavedDraft saved
draftRestoredRestored your draft from {time}.
discardConfirmDiscard what you’ve written?
discardDiscard
uploadInProgressPlease wait for your upload to finish.
joinTitleJoin the conversation
signInSign in
signInToCommentSign in to comment.
signInOrGuestSign in to comment and hear about replies, or post as a guest.
commentAsGuestComment as a guest
postingAsPosting as {name}
yourDetailsYour details
yourNameYour name
yourEmailYour email
notShownPubliclyNot shown publicly
replyEmailsEmail me when someone replies. We’ll ask you to confirm your address first.
followFollow
followingFollowing
followByEmailFollow by email
errorSomething went wrong. Please try again.
tryAgainTry again
moderatorModerator
moderatorViewModerator view.
reviewInCommentsReview in Comments
heldCount{count} held
reportedCount{count} reported
showHeldShow held
hideHeldHide held
approveApprove
markSpamMark as spam
notSpamNot spam
removeRemove
restoreRestore
keepKeep
spamSpam
gifGIF
gifAddAdd a GIF
gifSearchSearch GIPHY
gifResultsGIFs
gifRemoveRemove GIF
gifEmptyNo GIFs found.
gifPoweredByPowered by GIPHY
gifUnavailableGIFs can’t be loaded right now.
foldedReportsComment marked as inappropriate
foldedDownvotesComment hidden due to low rating
showFoldedShow comment
authorScoreTotal votes across this user’s comments
commentsComments
moderationModeration
onThisPageon this page
holdHold
removedNoteRemoved · only moderators see this
chooseOptionChoose…
addFilesAdd files
addFileAdd a file
removeFileRemove {name}
retryUploadTry {name} again
uploadingUploading…
uploaded{name} uploaded.
uploadFailed{name} didn’t upload.
fileRemoved{name} removed.
uploadLimitsUp to {count} files, {size} each.
uploadLimitUp to {size}.
fileTypeNotAllowed{name} can’t be added here. Choose {types}.
fileTooLarge{name} is larger than {size}.
tooManyFilesYou can add up to {count} files here.

When a request for the thread fails before any of these arrive, the thread falls back to its own English for the few labels it needs to say so, such as Try again.