Skip to content
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

Open
wants to merge 2 commits into
base: next-generation
Choose a base branch
from

Conversation

legendar
Copy link
Contributor

@legendar legendar commented Jun 1, 2020

No description provided.

export default function LoginView({ handleSubmit, submitting, valid }) {
useEffect(() => {
notification.success({
description: gettext('message description'),
Copy link
Contributor Author

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

Copy link
Contributor

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'),
Copy link
Contributor Author

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

Copy link
Contributor

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(
Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { gettext } = useTranslations()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants