-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gettext issues #244
base: next-generation
Are you sure you want to change the base?
gettext issues #244
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const errors = { | ||
required: 'Required', | ||
email: 'Email is wrong', | ||
required: gettext('Required'), | ||
email: gettext('Email is wrong'), | ||
} | ||
|
||
export default errors |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { useEffect } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { TextField } from 'common/forms' | ||
import classNames from './login.scss' | ||
import { notification } from 'antd' | ||
|
||
|
||
LoginView.propTypes = { | ||
|
@@ -14,13 +16,28 @@ LoginView.defaultProps = { | |
valid: true, | ||
} | ||
|
||
// ussage with variables | ||
const title = gettext('Login') | ||
|
||
export default function LoginView({ handleSubmit, submitting, valid }) { | ||
useEffect(() => { | ||
notification.success({ | ||
description: gettext('message description'), | ||
}) | ||
}, []) | ||
|
||
return ( | ||
<form onSubmit={handleSubmit} className={classNames.login}> | ||
<h2>Login</h2> | ||
<TextField name="email" label="Email" type="email" /> | ||
<TextField name="password" label="Password" type="password" /> | ||
<button disabled={submitting || !valid }>Login</button> | ||
<h2>{title}</h2> | ||
<TextField name="email" label={gettext('Email')} type="email" /> | ||
<TextField name="password" label={gettext('Password')} type="password" /> | ||
<button disabled={submitting || !valid }>{gettext('Login')}</button> | ||
<span dangerouslySetInnerHTML={{ | ||
__html: interpolate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sometimes we need to add html into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const { gettext } = useTranslations() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have HOC + HOOK + render prop + global function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same example as dangerouslySetInnerHTML we can use for placeholder, alert, promt... |
||
pgettext('EMAIL VALIDATION', 'It looks like an account with this email address already exists. Please %slog in%s to continue'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HOOK, HOC Render prop |
||
['<a href="/login/">', '</a>'], | ||
), | ||
}} /> | ||
</form> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gettext
will be executed in another context hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a case... Notification will render React Component