Skip to content

Commit

Permalink
Added missing messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Sep 8, 2020
1 parent ff85415 commit ccca5d2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
15 changes: 12 additions & 3 deletions components/forms/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const validate = ({ username, password }) => {
const errors = {};

if (!username) {
errors.username = 'Required';
errors.username = <FormattedMessage id="label.required" defaultMessage="Required" />;
}
if (!password) {
errors.password = 'Required';
errors.password = <FormattedMessage id="label.required" defaultMessage="Required" />;
}

return errors;
Expand All @@ -36,7 +36,16 @@ export default function LoginForm() {
if (typeof response !== 'string') {
await Router.push('/');
} else {
setMessage(response.startsWith('401') ? 'Incorrect username/password' : response);
setMessage(
response.startsWith('401') ? (
<FormattedMessage
id="message.incorrect-username-password"
defaultMessage="Incorrect username/password."
/>
) : (
response
),
);
}
};

Expand Down
2 changes: 1 addition & 1 deletion components/metrics/OSTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FormattedMessage } from 'react-intl';
export default function OSTable({ websiteId, limit, onExpand }) {
return (
<MetricsTable
title={<FormattedMessage id="metrics.operating-system" defaultMessage="Operating System" />}
title={<FormattedMessage id="metrics.operating-system" defaultMessage="Operating system" />}
type="os"
metric={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />}
websiteId={websiteId}
Expand Down
5 changes: 4 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
"message.failure": {
"defaultMessage": "Something went wrong."
},
"message.incorrect-username-password": {
"defaultMessage": "Incorrect username/password."
},
"message.save-success": {
"defaultMessage": "Saved successfully."
},
Expand Down Expand Up @@ -165,7 +168,7 @@
"defaultMessage": "Raw"
},
"metrics.operating-system": {
"defaultMessage": "Operating System"
"defaultMessage": "Operating system"
},
"metrics.page-views": {
"defaultMessage": "Page views"
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
"message.failure": {
"defaultMessage": "出现错误."
},
"message.incorrect-username-password": {
"defaultMessage": "用户名密码不正确."
},
"message.save-success": {
"defaultMessage": "成功保存."
},
Expand Down

0 comments on commit ccca5d2

Please sign in to comment.