Skip to content

Commit

Permalink
umputun#10 translate comment message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mavrin committed Feb 22, 2020
1 parent a359bc6 commit f1578a2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
22 changes: 17 additions & 5 deletions frontend/app/components/comment/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ const messages = defineMessages({
id: 'comment.unverified-user',
defaultMessage: 'Unverified user',
},
goToParent: {
id: 'comment.go-to-parent',
defaultMessage: 'Go to parent comment',
},
expiredTime: {
id: 'comment.expired-time',
defaultMessage: 'Editing time has expired.',
},
});

type PropsWithoutIntl = {
Expand Down Expand Up @@ -646,7 +654,7 @@ class Comment extends Component<Props, State> {
/>
);
}

const goToParentMessage = intl.formatMessage(messages.goToParent);
return (
<article
className={b('comment', { mix: this.props.mix }, defaultMods)}
Expand Down Expand Up @@ -702,8 +710,8 @@ class Comment extends Component<Props, State> {
<a
className="comment__link-to-parent"
href={`${o.locator.url}#${COMMENT_NODE_CLASSNAME_PREFIX}${o.pid}`}
aria-label="Go to parent comment"
title="Go to parent comment"
aria-label={goToParentMessage}
title={goToParentMessage}
onClick={e => this.scrollToParent(e)}
>
{' '}
Expand Down Expand Up @@ -758,7 +766,11 @@ class Comment extends Component<Props, State> {
<div className="comment__body">
{!!state.voteErrorMessage && (
<div className="voting__error" role="alert">
Voting error: {state.voteErrorMessage}
<FormattedMessage
id="comment.vote-error"
defaultMessage="Voting error: {voteErrorMessage}"
values={{ voteErrorMessage: state.voteErrorMessage }}
/>
</div>
)}

Expand Down Expand Up @@ -853,7 +865,7 @@ class Comment extends Component<Props, State> {
onSubmit={(text, _title) => this.updateComment(props.data.id, text)}
onCancel={this.toggleEditing}
getPreview={this.props.getPreview!}
errorMessage={state.editDeadline === null ? 'Editing time has expired.' : undefined}
errorMessage={state.editDeadline === null ? intl.formatMessage(messages.expiredTime) : undefined}
autofocus={true}
uploadImage={uploadImageHandler}
simpleView={StaticStore.config.simple_view}
Expand Down
5 changes: 4 additions & 1 deletion frontend/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@
"comment.block": "Block",
"comment.toggle-verification": "Toggle verification",
"comment.verified-user": "Verified user",
"comment.unverified-user": "Unverified user"
"comment.unverified-user": "Unverified user",
"comment.go-to-parent": "Go to parent comment",
"comment.expired-time": "Editing time has expired.",
"comment.vote-error": "Voting error: {voteErrorMessage}"
}
5 changes: 4 additions & 1 deletion frontend/app/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@
"comment.block": "Блокировать",
"comment.toggle-verification": "Toggle verification",
"comment.verified-user": "Verified user",
"comment.unverified-user": "Unverified user"
"comment.unverified-user": "Unverified user",
"comment.go-to-parent": "Go to parent comment",
"comment.expired-time": "Время редактирования истекло.",
"comment.vote-error": "Ошибка голосования: {voteErrorMessage}"
}

0 comments on commit f1578a2

Please sign in to comment.