mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 16:45:35 +01:00
Convert text for internationalization.
This commit is contained in:
parent
6833a5bdb0
commit
f0ac9b6522
36 changed files with 1091 additions and 196 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import React, { useState } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Formik, Form, Field } from 'formik';
|
||||
import { post } from 'lib/web';
|
||||
import Button from 'components/common/Button';
|
||||
|
|
@ -18,10 +19,10 @@ const validate = ({ user_id, username, password }) => {
|
|||
const errors = {};
|
||||
|
||||
if (!username) {
|
||||
errors.username = 'Required';
|
||||
errors.username = <FormattedMessage id="label.required" defaultMessage="Required" />;
|
||||
}
|
||||
if (!user_id && !password) {
|
||||
errors.password = 'Required';
|
||||
errors.password = <FormattedMessage id="label.required" defaultMessage="Required" />;
|
||||
}
|
||||
|
||||
return errors;
|
||||
|
|
@ -36,7 +37,11 @@ export default function AccountEditForm({ values, onSave, onClose }) {
|
|||
if (typeof response !== 'string') {
|
||||
onSave();
|
||||
} else {
|
||||
setMessage(response || 'Something went wrong');
|
||||
setMessage(
|
||||
response || (
|
||||
<FormattedMessage id="message.failure" defaultMessage="Something went wrong." />
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -50,20 +55,26 @@ export default function AccountEditForm({ values, onSave, onClose }) {
|
|||
{() => (
|
||||
<Form>
|
||||
<FormRow>
|
||||
<label htmlFor="username">Username</label>
|
||||
<label htmlFor="username">
|
||||
<FormattedMessage id="label.username" defaultMessage="Username" />
|
||||
</label>
|
||||
<Field name="username" type="text" />
|
||||
<FormError name="username" />
|
||||
</FormRow>
|
||||
<FormRow>
|
||||
<label htmlFor="password">Password</label>
|
||||
<label htmlFor="password">
|
||||
<FormattedMessage id="label.password" defaultMessage="Password" />
|
||||
</label>
|
||||
<Field name="password" type="password" />
|
||||
<FormError name="password" />
|
||||
</FormRow>
|
||||
<FormButtons>
|
||||
<Button type="submit" variant="action">
|
||||
Save
|
||||
<FormattedMessage id="button.save" defaultMessage="Save" />
|
||||
</Button>
|
||||
<Button onClick={onClose}>
|
||||
<FormattedMessage id="button.cancel" defaultMessage="Cancel" />
|
||||
</Button>
|
||||
<Button onClick={onClose}>Cancel</Button>
|
||||
</FormButtons>
|
||||
<FormMessage>{message}</FormMessage>
|
||||
</Form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue