add translations

This commit is contained in:
Nuwan 2024-02-14 11:37:01 +05:30
parent 861722e5d4
commit fd9632a26c
5 changed files with 112 additions and 52 deletions

View File

@ -18,7 +18,7 @@ import {
function JKEditProfile() {
const { t } = useTranslation();
const { t } = useTranslation('profile');
const { currentUser } = useAuth();
const [musicInstruments, setMusicInstruments] = useState([]);
const [genres, setGenres] = useState([]);
@ -36,9 +36,9 @@ function JKEditProfile() {
const regionRef = useRef(null);
const PROFICIENCIES = [
{ value: '1', label: 'Beginner' },
{ value: '2', label: 'Intermediate' },
{ value: '3', label: 'Advanced' }
{ value: '1', label: t('profeciency.beginner') },
{ value: '2', label: t('profeciency.intermediate') },
{ value: '3', label: t('profeciency.advanced') }
];
const { register, control, handleSubmit, setValue, getValues } = useForm({
@ -377,13 +377,13 @@ function JKEditProfile() {
<Col>
<Card>
<CardHeader>
<h5>Basics</h5>
<h5>{t('basics')}</h5>
</CardHeader>
<CardBody className="bg-light">
<Row>
<Col md={4}>
<FormGroup>
<Label for="firstName">First Name</Label>
<Label for="firstName">{t('first_name')}</Label>
<Controller
name="firstName"
control={control}
@ -401,7 +401,7 @@ function JKEditProfile() {
</Col>
<Col md={4}>
<FormGroup>
<Label for="lastName">Last Name</Label>
<Label for="lastName">{t('last_name')}</Label>
<Controller
name="lastName"
control={control}
@ -423,7 +423,7 @@ function JKEditProfile() {
<JKCurrentUserAvatar size="sm" />
</div>
<div>
<a href="#">Change Photo</a>
<a href="#">{t('change_photo')}</a>
</div>
</div>
</Col>
@ -431,7 +431,7 @@ function JKEditProfile() {
<Row>
<Col md={4}>
<FormGroup>
<Label for="country">Country</Label>
<Label for="country">{t('country')}</Label>
{countries.length > 0 && (
<Controller
name="country"
@ -454,7 +454,7 @@ function JKEditProfile() {
</Col>
<Col md={4}>
<FormGroup>
<Label for="state">State / Province</Label>
<Label for="state">{t('state')}</Label>
{regions.length > 0 && (
<Controller
name="state"
@ -478,7 +478,7 @@ function JKEditProfile() {
</Col>
<Col md={4}>
<FormGroup>
<Label for="city">City</Label>
<Label for="city">{t('city')}</Label>
<Controller
name="city"
control={control}
@ -497,7 +497,7 @@ function JKEditProfile() {
</Col>
</Row>
<FormGroup>
<Label for="biography">Musical biography</Label>
<Label for="biography">{t('musical_biography')}</Label>
<Controller
name="biography"
control={control}
@ -530,7 +530,7 @@ function JKEditProfile() {
)}
/>
<Label check for="subscribeEmail">
Accept emails from JamKazam about the JamKazam services
{t('accept_emails')}
</Label>
</FormGroup>
</CardBody>
@ -538,7 +538,7 @@ function JKEditProfile() {
<Card className="mt-3">
<CardHeader>
<h5>Interests</h5>
<h5>{t('interests')}</h5>
</CardHeader>
<CardBody className="bg-light">
<FormGroup check>
@ -557,7 +557,7 @@ function JKEditProfile() {
)}
/>
<Label check for="check">
I'm interested in joining a virtual/online band
{t('interest_joining_virtual_band')}
</Label>
</FormGroup>
<FormGroup check>
@ -576,7 +576,7 @@ function JKEditProfile() {
)}
/>
<Label check for="check">
I'm interested in joining an in-person band
{t('interest_joining_in_person_band')}
</Label>
</FormGroup>
<FormGroup check>
@ -595,7 +595,7 @@ function JKEditProfile() {
)}
/>
<Label check for="check">
I'm interested in co-writing songs with others
{t('interest_cowriting_songs')}
</Label>
</FormGroup>
</CardBody>
@ -604,7 +604,7 @@ function JKEditProfile() {
<Col>
<Card>
<CardHeader>
<h5>Instruments</h5>
<h5>{t('instruments')}</h5>
</CardHeader>
<CardBody className="bg-light" style={{ overflowY: 'scroll', height: 300 }}>
<FormGroup check>
@ -647,7 +647,7 @@ function JKEditProfile() {
</Card>
<Card className="mt-3">
<CardHeader>
<h5>Genres</h5>
<h5>{t('genres')}</h5>
</CardHeader>
<CardBody className="bg-light" style={{ overflowY: 'scroll', height: 300 }}>
<FormGroup check>

View File

@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import {
Card,
CardHeader,
CardBody,
@ -50,7 +49,7 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
const { new_email, current_password } = data;
postUpdateAccountEmail(currentUser.id, { email: new_email, current_password })
.then(response => {
setAlert('A confirmation email has been sent to your email. Please check your email and click the link to confirm your new email address.');
setAlert(t('identity.email_form.alerts.confirmation_email_sent'));
setValue('current_password', '');
setValue('new_email', '');
toggleAlert()
@ -64,7 +63,7 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
errors.current_password.forEach(error => {
setError('current_password', {
type: 'manual',
message: `Current password ${error}`
message: `${t('identity.email_form.current_password')} ${error}`
})
})
}
@ -72,7 +71,7 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
errors.update_email.forEach(error => {
setError('new_email', {
type: 'manual',
message: `New email ${error}`
message: `${t('identity.email_form.new_email')} ${error}`
})
})
}
@ -87,21 +86,20 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
return (
<Card>
<CardHeader>
<h5>Email</h5>
<h5>{t('identity.email_form.title')}</h5>
</CardHeader>
<CardBody className="bg-light" style={{ minHeight: 300 }}>
<small>
To update the email associated with your account, enter your current password (for security reasons) and the
new email, and click the "Save Email" button.
{t('identity.email_form.help_text')}
</small>
<Form className="mt-2" onSubmit={handleSubmit(onSubmitEmail)}>
<FormGroup>
<Label for="current_password">Current Password</Label>
<Label for="current_password">{t('identity.email_form.current_password')}</Label>
<Controller
name="current_password"
control={control}
rules={{ required: 'Current password is required' }}
rules={{ required: t('identity.email_form.validations.current_password.required') }}
render={({ field }) => (
<InputGroup>
<Input
@ -109,7 +107,7 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
type={showEmailPassword ? 'text' : 'password'}
className="form-control"
id="current_password"
placeholder="Current Password"
placeholder={t('identity.email_form.current_password')}
/>
<InputGroupAddon
addonType="append"
@ -127,15 +125,15 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
{errors.current_password && <div className="text-danger"><small>{errors.current_password.message}</small></div>}
</FormGroup>
<FormGroup>
<Label for="new_email">New Email</Label>
<Label for="new_email">{t('identity.email_form.new_email')}</Label>
<Controller
name="new_email"
control={control}
rules={{
required: 'New email is required',
required: t('identity.email_form.validations.new_email.required'),
pattern: {
value: /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/,
message: 'Invalid email address'
message: t('identity.email_form.validations.new_email.pattern')
}
}}
render={({ field }) => (
@ -144,14 +142,14 @@ const JKEditEmail = ({setAlert, toggleAlert}) => {
type="email"
className="form-control"
id="new_email"
placeholder={user ? user.email : 'New Email'}
placeholder={user ? user.email : t('identity.email_form.new_email')}
/>
)}
/>
{errors.new_email && <div className="text-danger"><small>{errors.new_email.message}</small></div>}
</FormGroup>
<div className='d-flex align-content-center justify-content-start'>
<input type="submit" className="btn btn-primary" value="Save Email" disabled={submitting} />
<input type="submit" className="btn btn-primary" value={t('identity.email_form.submit')} disabled={submitting} />
<span className='ml-2'>
{ submitting && <FontAwesomeIcon icon="spinner" />}
</span>

View File

@ -40,7 +40,7 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
const { new_password, current_password } = data;
postUpdateAccountPassword(currentUser.id, { current_password, new_password })
.then(response => {
setAlert('Your password has been successfully updated.');
setAlert(t('identity.password_form.alerts.updated'));
setValue('current_password', '');
setValue('new_password', '');
toggleAlert();
@ -55,7 +55,7 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
errors.current_password.forEach(error => {
setError('current_password', {
type: 'manual',
message: `Current password ${error}`
message: `${t('identity.password_form.current_password')} ${error}`
});
});
}
@ -63,7 +63,7 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
errors.password.forEach(error => {
setError('new_password', {
type: 'manual',
message: `New password ${error}`
message: `${t('identity.password_form.new_password')} ${error}`
});
});
}
@ -81,9 +81,7 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
}
try {
await requestPasswordReset(currentUser.id);
setAlert(
'A password reset email has been sent to your email. Please check your email and click the link to reset your password.'
);
setAlert(t('identity.password_form.alerts.password_reset_email_sent'));
toggleAlert();
} catch (error) {
console.log(error);
@ -97,17 +95,16 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
</CardHeader>
<CardBody className="bg-light" style={{ minHeight: 300 }}>
<small>
To update the password associated with your account, enter your current password (for security reasons) and
the new password, and click the "Save Password" button.
{t('identity.password_form.help_text')}
</small>
<Form className="mt-2" onSubmit={handleSubmit(onSubmitPassword)}>
<FormGroup>
<Label for="current_password">Current Password</Label>
<Label for="current_password"> {t('identity.password_form.current_password')}</Label>
<Controller
name="current_password"
control={control}
rules={{ required: 'Current password is required' }}
rules={{ required: t('identity.password_form.validations.current_password.required') }}
render={({ field }) => (
<InputGroup>
<Input
@ -115,7 +112,7 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
type={showPassword ? 'text' : 'password'}
className="form-control"
id="current_password"
placeholder="Current Password"
placeholder={t('identity.password_form.current_password')}
/>
<InputGroupAddon
addonType="append"
@ -138,11 +135,11 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
</FormGroup>
<FormGroup>
<Label for="new_password">New Password</Label>
<Label for="new_password">{t('identity.password_form.new_password')}</Label>
<Controller
name="new_password"
control={control}
rules={{ required: 'New password is required' }}
rules={{ required: t('identity.password_form.validations.new_password.required') }}
render={({ field }) => (
<InputGroup>
<Input
@ -172,15 +169,13 @@ const JKEditPassword = ({ setAlert, toggleAlert }) => {
)}
</FormGroup>
<div className="d-flex align-content-center justify-content-start">
<input type="submit" className="btn btn-primary" value="Save Password" disabled={submitting} />
<input type="submit" className="btn btn-primary" value={t('identity.password_form.submit')} disabled={submitting} />
<span className="ml-2">{submitting && <FontAwesomeIcon icon="spinner" />}</span>
</div>
</Form>
<div className="mt-2">
<small>
If you can not remember your current password, <a href="#" onClick={requestResetPassword}>Click here</a> to reset
your password, and you will receive an email with instructions on how to reset your password to the email
address associated with your JamKazam account.
{t('identity.password_form.forgot_password.help_text_p1')} <a href="#" onClick={requestResetPassword}>{t('identity.password_form.forgot_password.click_here')}</a> {t('identity.password_form.forgot_password.help_text_p2')}
</small>
</div>
</CardBody>

View File

@ -5,7 +5,54 @@
"update_notification": {
"title": "Account Identity Updated"
}
},
"email_form": {
"title": "Email",
"help_text": "To update the email associated with your account, enter your current password (for security reasons) and the new email, and click the \"Save Email\" button.",
"current_password": "Current Password",
"new_email": "New Email",
"submit": "Save Email",
"validations": {
"new_email": {
"required": "New Email is required",
"pattern": "Email is invalid"
},
"current_password": {
"required": "Current password is required"
}
},
"alerts": {
"updated": "Your account identity has been updated.",
"confirmation_email_sent": "A confirmation email has been sent to your email address. Please click the link in the email to confirm your email address."
}
},
"password_form": {
"title": "Password",
"help_text": "To update the password associated with your account, enter your current password (for security reasons) and the new password, and click the \"Save Password\" button.",
"current_password": "Current Password",
"new_password": "New Password",
"submit": "Save Password",
"validations": {
"new_password": {
"required": "New Password is required",
"pattern": "Password must be at least 8 characters long"
},
"current_password": {
"required": "Current password is required"
}
},
"alerts": {
"updated": "Your password has been successfully updated.",
"password_reset_email_sent": "A password reset email has been sent to your email. Please check your email and click the link to reset your password."
},
"forgot_password": {
"help_text_p1": "If you can not remember your current password",
"click_here": "click here",
"help_text_p2": "to reset your password, and you will receive an email with instructions on how to reset your password to the email address associated with your JamKazam account."
}
}
}
}

View File

@ -1,3 +1,23 @@
{
"page_title": "Profile"
"page_title": "Profile",
"profeciency": {
"beginner": "Beginner",
"intermediate": "Intermediate",
"advanced": "Advanced"
},
"basics": "Basics",
"interests": "Interests",
"instruments": "Instruments",
"genres": "Genres",
"first_name": "First Name",
"last_name": "Last Name",
"change_photo": "Change Photo",
"country": "Country",
"state": "State/Province",
"city": "City",
"musical_biography": "Musical Biography",
"accept_emails": "Accept emails from JamKazam about the JamKazam services",
"interest_joining_virtual_band": "I'm interested in joining a virtual/online band",
"interest_joining_in_person_band": "I'm interested in joining an in-person band",
"interest_cowriting_songs": "I'm interested in co-writing songs with others"
}