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

Fix #9 add localization to login component using react-intl package #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jessemao
Copy link

@jessemao jessemao commented Feb 21, 2017

#9 Wrapped Login with react-intl

screen shot 2017-02-21 at 3 24 28 pm

screen shot 2017-02-21 at 3 24 02 pm

@jessemao jessemao changed the title add localization to login component using react-intl package Fix #9 add localization to login component using react-intl package Feb 21, 2017
}
}

Input.propTypes = {
Copy link
Collaborator

@dennismphil dennismphil Feb 21, 2017

Choose a reason for hiding this comment

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

Can you use the static PropType syntax here

Copy link
Collaborator

@dennismphil dennismphil left a comment

Choose a reason for hiding this comment

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

We may need to rename all the jsx files as part of this commit

render() {
const {theme, username, password, remember, onUsernameChange, onPasswordChange, onRememberToggle, onLogin, locale} = this.props;
return (
<IntlProvider locale={locale} messages={getLocaleMessage(locale)}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel wrapping every component with localization wrapper feels like an overkill. Instead, can we do this once is App and use redux store to save the locale and use connect to listen to it

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, putting this in Redux is a good solution because we can dynamically load it from the server.

onUsernameChange: PropTypes.func,
onPasswordChange: PropTypes.func,
onRememberToggle: PropTypes.func,
onLogin: PropTypes.func,
Copy link
Collaborator

Choose a reason for hiding this comment

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

All these are required properties?

@@ -0,0 +1,11 @@
export default {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make these json files?

"react-redux": "^4.4.6",
"react-router": "^3.0.0",
"redux": "^3.6.0",
"redux-thunk": "^2.1.0"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have all of these external dependencies all of a sudden? We shouldn't need any of these... Specifically, our only external dependency would be React, but we webpack everything up when we build, so our exports can be used anywhere regardless of environment.

import {
intlShape,
injectIntl
} from 'react-intl';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really a fan of this style except when you are importing a lot of items. We should decide if we like this and consider allowing/disallowing it in our linting rules.

}
}

Input.propTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be static propTypes = {...} inside the class.

placeholder: PropTypes.object,
};

Input.defaultProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

static defaultProps = {..}

@@ -0,0 +1,148 @@
import React, { Component, PropTypes } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently not putting .jsx extensions on code. If we want to, we should be consistent about it. I do not have a strong opinion on whether we should or should not.

import enMessage from './l10n/en_US';

addLocaleData(enLocaleData);
addLocaleData(zhLocaleData);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we bundling all of the locale data inside webpack? Won't this make our exports huge?

render() {
const {theme, username, password, remember, onUsernameChange, onPasswordChange, onRememberToggle, onLogin, locale} = this.props;
return (
<IntlProvider locale={locale} messages={getLocaleMessage(locale)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, putting this in Redux is a good solution because we can dynamically load it from the server.

SUBMIT: 'Submit',
FULLNAME: 'Full name',
REGISTER: 'Register',
'placeholder.username': 'Please input your username',
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of mixing ALLCAPS with dot.format.

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

Successfully merging this pull request may close these issues.

3 participants