-
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
Conversation
export default function LoginView({ handleSubmit, submitting, valid }) { | ||
useEffect(() => { | ||
notification.success({ | ||
description: gettext('message description'), |
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 here
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.
this is not a case... Notification will render React Component
<button disabled={submitting || !valid }>{gettext('Login')}</button> | ||
<span dangerouslySetInnerHTML={{ | ||
__html: interpolate( | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
pgettext
used to get string for context and should be normally used inside interpolate
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.
HOOK, HOC Render prop
<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 comment
The reason will be displayed to describe this comment to others. Learn more.
sometimes we need to add html into interpolate
. we need to suggest another solution for such cases
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.
const { gettext } = useTranslations()
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.
we have HOC + HOOK + render prop + global function
https://django-stars.github.io/frontend-docs/docs/i18n/i18n_about#withtranslations-hoc
https://django-stars.github.io/frontend-docs/docs/i18n/i18n_about#usetranslations-hook
https://django-stars.github.io/frontend-docs/docs/i18n/i18n_about#translator-render-props
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.
same example as dangerouslySetInnerHTML we can use for placeholder, alert, promt...
No description provided.