Skip to content

Commit

Permalink
umputun#10 localize some comment message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mavrin committed Feb 18, 2020
1 parent f2d4d79 commit 8af1e0d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
45 changes: 43 additions & 2 deletions frontend/app/components/comment/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ defineMessages({
id: 'comment.hide-user-comment',
defaultMessage: 'Do you want to hide comments of {userName}?',
},
'comment.pin-comment': {
id: 'comment.pin-comment',
defaultMessage: 'Do you want to pin this comment?',
},
'comment.unpin-comment': {
id: 'comment.unpin-comment',
defaultMessage: 'Do you want to unpin this comment?',
},
'comment.verify-user': {
id: 'comment.verify-user',
defaultMessage: 'Do you want to verify {userName}?',
},
'comment.unverify-user': {
id: 'comment.unverify-user',
defaultMessage: 'Do you want to unverify {userName}?',
},
});

export type Props = {
Expand Down Expand Up @@ -178,7 +194,16 @@ export class Comment extends Component<Props, State> {

togglePin = () => {
const value = !this.props.data.pin;
const promptMessage = `Do you want to ${value ? 'pin' : 'unpin'} this comment?`;
const intl = this.props.intl;
const promptMessage = value
? intl.formatMessage({
id: 'comment.pin-comment',
defaultMessage: 'comment.pin-comment',
})
: intl.formatMessage({
id: 'comment.unpin-comment',
defaultMessage: 'comment.unpin-comment',
});

if (confirm(promptMessage)) {
this.props.setPinState!(this.props.data.id, value);
Expand All @@ -188,7 +213,23 @@ export class Comment extends Component<Props, State> {
toggleVerify = () => {
const value = !this.props.data.user.verified;
const userId = this.props.data.user.id;
const promptMessage = `Do you want to ${value ? 'verify' : 'unverify'} ${this.props.data.user.name}?`;
const intl = this.props.intl;
const userName = this.props.data.user.name;
const promptMessage = value
? intl.formatMessage(
{
id: 'comment.verify-user',
defaultMessage: 'comment.verify-user',
},
{ userName }
)
: intl.formatMessage(
{
id: 'comment.unverify-user',
defaultMessage: 'unverify-user',
},
{ userName }
);

if (confirm(promptMessage)) {
this.props.setVerifyStatus!(userId, value);
Expand Down
6 changes: 5 additions & 1 deletion frontend/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@
"commentsSort.least-recently-updated": "Least recently updated",
"commentsSort.most-controversial": "Most controversial",
"commentsSort.least-controversial": "Least controversial",
"commentSort.sort-by": "Sort by"
"commentSort.sort-by": "Sort by",
"comment.pin-comment": "Do you want to pin this comment?",
"comment.unpin-comment": "Do you want to unpin this comment?",
"comment.verify-user": "Do you want to verify {userName}?",
"comment.unverify-user": "Do you want to unverify {userName}?"
}
8 changes: 6 additions & 2 deletions frontend/app/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"comment.delete": "Удалить",
"comment.time": "{day} в {time}",
"authPanel.other-provider": "Другой",
"authPanel.request-to-delete-data": "Request my data removal",
"authPanel.request-to-delete-data": "Запросить удаление моих данных",
"authPanel.anonymous-provider": "Анонимно",
"authPanel.or-provider": "или",
"authPanel.disabled-cookies": "Disable third-party cookies blocking to login or open comments in",
Expand All @@ -33,5 +33,9 @@
"commentsSort.least-recently-updated": "Давно обновленные",
"commentsSort.most-controversial": "Наиболее спорные",
"commentsSort.least-controversial": "Наименее спорные",
"commentSort.sort-by": "Сортировать по"
"commentSort.sort-by": "Сортировать по",
"comment.pin-comment": "Закрепить комментарий?",
"comment.unpin-comment": "Открепить комментарий?",
"comment.verify-user": "Do you want to verify {userName}?",
"comment.unverify-user": "Do you want to unverify {userName}?"
}

0 comments on commit 8af1e0d

Please sign in to comment.