Commit 57f88105 authored by 2breakegg's avatar 2breakegg

i18n

parent ce856731
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"parser": "babel-eslint", "parser": "babel-eslint",
"extends": "airbnb", "extends": "airbnb",
"rules": { "rules": {
"react/jsx-space-before-closing":[0],
"generator-star-spacing": [0], "generator-star-spacing": [0],
"consistent-return": [0], "consistent-return": [0],
"react/forbid-prop-types": [0], "react/forbid-prop-types": [0],
......
...@@ -10,3 +10,4 @@ ...@@ -10,3 +10,4 @@
.DS_Store .DS_Store
npm-debug.log* npm-debug.log*
/utils/config.js
{ {
"en": { "en": {
"Login": "Login", "language": "中文",
"Username": "Username" "l": "zh-CN",
"username": "User Name",
"email": "E-Mail",
"password": "Password",
"user-info": "User Info",
"reset-info": "Reset User Info",
"avatar": "Avatar",
"nickname": "Nickname",
"reset-account-info": "Reset Account info",
"current_password": "Current Password",
"password-again": "Input Password Again",
"save": "Save",
"nickname": "Nickname[optional]",
"crop": "Crop Image",
"moecube": "MoeCube",
"index-leftbox1": "You can use this account to sign in.",
"yonghuan": "The Disappearing of Gensokyo",
"please-sign-up": "Sign Up",
"please-sign-in": "Sign In",
"email-address-or-username": "E-Mail or Username",
"register-now": "register-now!",
"register":"register",
"login": "Login",
"forgot-password": "Forgot Password",
"send-email": "Send Email",
"reset-success": "reset success",
"reset-fail": "reset fail",
"reset-password": "Reset Password",
"remember-me":"Remember me",
"Please use a correct E-Mail address.": "Please use a correct E-Mail address.",
"User name can not be empty.": "User name can not be empty.",
"You can not use this username.": "You can not use this username.",
"You can use this password.": "You can use this password.",
"Password is too long.": "Password is too long.",
"Password is too short.": "Password is too short.",
"Password is correct.": "Password is correct.",
"Incorrect password.2": "Incorrect password.",
"The E-Mail has been sent.": "The E-Mail has been sent.",
"Incorrect user name or password.": "Incorrect user name or password.",
"E-Mail address can not be blank.": "E-Mail address can not be blank.",
"User name can not be blank.": "User name can not be blank.",
"Password can not be blank.": "Password can not be blank.",
"Please input your password again.": "Please input your password again.",
"Please use a correct E-Mail address.": "Please use a correct E-Mail address.",
"This E-Mail address has been token.": "This E-Mail address has been token.",
"You can use this E-mail address.": "You can use this E-mail address.",
"This user name has been token.": "This user name has been token.",
"You can use this user name.": "You can use this user name.",
"Password is not correct.": "Password is not correct.",
"User does not exisit.": "User does not exisit.",
"Incorrect password.": "Incorrect password.",
"Please check your registration info again.": "Please check your registration info again.",
"Your account has not been verified.": "Your account has not been verified. Please check the verification email we have sent to you. You will be able to log in after verification.",
"A password reset email has been sent to you.": "A password reset email has been sent to you. Please check the email to continue.",
"Your account has been created.": "Your account has been created. You will receive an verification email. Please check the mail to finish registration. ",
"Error": "Error",
"Your account has been successfully activated!": "Your account has been successfully activated!",
"close": "close",
"reset-email": "reset email",
"send-email2": "send email",
"didnt receive verification email 1": "If you didn't receive the verification email, please click ",
"didnt receive verification email 2": "to resend it again.",
"A verification email has been sent to you.": "A verification email has been sent to you, please check your email to finish verification.",
"Your email has been updated.": "Your email has been updated. You will receive an verification email. Please check the mail to finish verification. ",
"Please input your account!":"Please input your email or username!",
"Please input your Password!":"Please input your Password!"
}, },
"zh": { "zh": {
"Login": "登录", "language": "english",
"Username": "用户名" "l": "en-US",
"username": "用户名",
"email": "邮箱",
"password": "密码",
"user-info": "用户信息",
"reset-info": "修改信息",
"avatar": "头像",
"nickname": "昵称[选填]",
"reset-account-info": "修改账户信息",
"current_password": "原密码",
"password-again": "再次输入密码",
"save": "保存",
"nickname[optional]": "昵称[选填]",
"crop": "截图",
"moecube": "萌立方",
"index-leftbox1": "您可使用以下几种账号登陆",
"yonghuan": "永远消失的幻想乡",
"please-sign-up": "注册",
"please-sign-in": "登陆",
"email-address-or-username": "邮箱或用户名",
"register-now": "现在注册",
"register":"注册",
"login": "登陆",
"forgot-password": "忘记密码",
"send-email": "发送邮件",
"reset-success": "修改成功",
"reset-fail": "修改失败",
"reset-password": "重设密码",
"remember-me":"记住我",
"Please use a correct E-Mail address.": "请填写正确的邮箱地址",
"User name can not be empty.": "不能为空",
"You can not use this username.": "用户名不合法",
"You can use this password.": "密码可以使用",
"Password is too long.": "密码过长",
"Password is too short.": "密码过短",
"Password is correct.": "密码一致",
"Incorrect password.2": "密码不一致",
"The E-Mail has been sent.": "邮件已发送",
"Incorrect-user-name-or-password": "用户或密码错误",
"E-Mail-address-can-not-be-blank": "邮箱地址不能为空",
"User name can not be blank.": "用户名不能为空",
"Password can not be blank": "密码不能为空",
"Please input your password again.": "确认密码不能为空",
"Please use a correct E-Mail address.": "邮箱格式错误",
"This E-Mail address has been token.": "该邮箱已被注册",
"You can use this E-mail address.": "邮箱可以使用",
"This user name has been token.": "该用户名已被注册",
"You can use this user name.": "用户名可以使用",
"Password is not correct.": "密码不一致",
"User does not exisit.": "用户不存在",
"Incorrect password.": "密码不正确",
"Please check your registration info again.": "请填写正确的注册信息。",
"Your account has not been verified.": "您的账户还未完成验证,请查看激活邮件,激活后即可登陆。",
"A password reset email has been sent to you.": "密码重置邮件已发送,请查看邮件继续下一步。",
"Your account has been created.": "您的账号已经创建。您将会收到一封验证邮件,请查看邮件完成注册。",
"Error": "出问题了",
"Your account has been successfully activated!": "账号激活成功!",
"close": "关闭",
"reset-email": "更改邮箱",
"send-email2": "重发邮件",
"didnt receive verification email 1": "如果您没有收到验证邮件,请点击",
"didnt receive verification email 2": "获取验证邮件。",
"A verification email has been sent to you.": "已经向您发送了一封验证邮件,请您查看Email完成验证。",
"Your email has been updated.": "邮箱已经更新,您将会收到一封验证邮件,请您查看Email完成验证。",
"Please input your account!":"请填写你的邮箱或用户名!",
"Please input your Password!":"请填写你的密码!",
"密码至少为8-24位":"密码至少为8-24位"
} }
} }
\ No newline at end of file
export default { export default {
// apiRoot: 'http://localhost:3000', // apiRoot: 'http://localhost:3000',
apiRoot: 'http://192.168.1.107:3000', apiRoot: 'http://192.168.1.126:3000',
}; };
...@@ -59,4 +59,4 @@ ReactDOM.render( ...@@ -59,4 +59,4 @@ ReactDOM.render(
); );
console.log(language) console.log(language)
\ No newline at end of file
...@@ -141,7 +141,7 @@ export default { ...@@ -141,7 +141,7 @@ export default {
}, },
*checkEmail({ payload }, { call, put }) { *checkEmail({ payload }, { call, put }) {
const { data } = yield call(checkUserExists, payload) const { data } = yield call(checkUserExists, payload)
console.log(data);
if(data) { if(data) {
yield put({ type: 'check', payload: { isEmailExists: true , checkEmail: 'warning'}}) yield put({ type: 'check', payload: { isEmailExists: true , checkEmail: 'warning'}})
} else { } else {
...@@ -178,7 +178,7 @@ export default { ...@@ -178,7 +178,7 @@ export default {
} }
} catch (error) { } catch (error) {
yield put({ type: 'forgotFail' }) yield put({ type: 'forgotFail' })
message.error(error.message) message.error(error.message)
} }
}, },
*register({ payload }, { call, put }) { *register({ payload }, { call, put }) {
......
import { Button, Form, Icon, Input, Select, Spin } from 'antd'; import { Button, Form, Icon, Input, Select, Spin } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import { Link } from 'dva/router'; import { Link } from 'dva/router';
import React from 'react'; import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
const FormItem = Form.Item; const FormItem = Form.Item;
const Option = Select.Option; const Option = Select.Option;
...@@ -19,6 +21,10 @@ const formItemLayout = { ...@@ -19,6 +21,10 @@ const formItemLayout = {
class Login extends React.Component { class Login extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
onSubmitLogin = (e) => { onSubmitLogin = (e) => {
const { form, dispatch, params: { id } } = this.props; const { form, dispatch, params: { id } } = this.props;
...@@ -37,6 +43,7 @@ class Login extends React.Component { ...@@ -37,6 +43,7 @@ class Login extends React.Component {
render() { render() {
const { getFieldDecorator, dispatch } = this.props.form; const { getFieldDecorator, dispatch } = this.props.form;
const { isForgotSubmit = false } = this.props; const { isForgotSubmit = false } = this.props;
const { intl: { messages } } = this.context;
return ( return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
...@@ -46,14 +53,14 @@ class Login extends React.Component { ...@@ -46,14 +53,14 @@ class Login extends React.Component {
{getFieldDecorator('email', { {getFieldDecorator('email', {
rules: [{ required: true, message: 'Please input your username or email!' }], rules: [{ required: true, message: 'Please input your username or email!' }],
})( })(
<Input prefix={<Icon type="user" style={{ fontSize: 13 }}/>} placeholder="username or email"/>, <Input prefix={<Icon type="user" style={{ fontSize: 13 }}/>} placeholder={messages['email-address-or-username']} />,
)} )}
</FormItem> </FormItem>
<Button type="primary" htmlType="submit" className="login-form-button"> <Button type="primary" htmlType="submit" className="login-form-button">
Send <Format id={'send-email'} />
</Button> </Button>
Or <Link to="/login">Sign In</Link> Or <Link to="/login"><Format id={'login'} /></Link>
</Form> </Form>
</Spin> </Spin>
</div> </div>
......
import { Button, Checkbox, Form, Icon, Input, Spin } from 'antd'; import { Button, Checkbox, Form, Icon, Input, Spin } from 'antd';
import { FormattedMessage as Format } from 'react-intl'
import { connect } from 'dva'; import { connect } from 'dva';
import { Link } from 'dva/router'; import { Link } from 'dva/router';
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import "./Login.less" import { FormattedMessage as Format } from 'react-intl';
import './Login.less';
const FormItem = Form.Item; const FormItem = Form.Item;
class Login extends React.Component { class Login extends React.Component {
static contextTypes = { static contextTypes = {
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
} }
...@@ -32,7 +32,7 @@ class Login extends React.Component { ...@@ -32,7 +32,7 @@ class Login extends React.Component {
render() { render() {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const { isLoginSubmit = false } = this.props; const { isLoginSubmit = false } = this.props;
const { intl: {messages} } = this.context const { intl: { messages } } = this.context;
return ( return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
...@@ -40,16 +40,16 @@ class Login extends React.Component { ...@@ -40,16 +40,16 @@ class Login extends React.Component {
<Form onSubmit={this.onSubmitLogin} className="login-form"> <Form onSubmit={this.onSubmitLogin} className="login-form">
<FormItem> <FormItem>
{getFieldDecorator('account', { {getFieldDecorator('account', {
rules: [{ required: true, message: 'Please input your account!' }], rules: [{ required: true, message: messages['Please input your account!'] }],
})( })(
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder={messages["Username"]} />, <Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder={messages['email-address-or-username']} />,
)} )}
</FormItem> </FormItem>
<FormItem> <FormItem>
{getFieldDecorator('password', { {getFieldDecorator('password', {
rules: [{ required: true, message: 'Please input your Password!' }], rules: [{ required: true, message: messages['Please input your Password!'] }],
})( })(
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />, <Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder={messages.password} />,
)} )}
</FormItem> </FormItem>
<FormItem> <FormItem>
...@@ -57,13 +57,13 @@ class Login extends React.Component { ...@@ -57,13 +57,13 @@ class Login extends React.Component {
valuePropName: 'checked', valuePropName: 'checked',
initialValue: true, initialValue: true,
})( })(
<Checkbox>Remember me</Checkbox>, <Checkbox><Format id={'remember-me'} /></Checkbox>,
)} )}
<Link to="/forgot" className="login-form-forgot">Forgot password</Link> <Link to="/forgot" className="login-form-forgot"><Format id={'forgot-password'} /></Link>
<Button type="primary" htmlType="submit" className="login-form-button"> <Button type="primary" htmlType="submit" className="login-form-button">
<Format id={"Login"} /> <Format id={'login'} />
</Button> </Button>
Or <Link to="/register">register now!</Link> Or <Link to="/register"><Format id={'register-now'} /></Link>
</FormItem> </FormItem>
</Form> </Form>
</Spin> </Spin>
......
import { Button, Form, Icon, Input, Select, Spin } from 'antd'; import { Button, Form, Icon, Input, Select, Spin } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import { Link } from 'dva/router'; import { Link } from 'dva/router';
import React from 'react'; import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
const FormItem = Form.Item; const FormItem = Form.Item;
const Option = Select.Option; const Option = Select.Option;
class Register extends React.Component { class Register extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
onSubmitLogin = (e) => { onSubmitLogin = (e) => {
const { form, dispatch, params: { id } } = this.props; const { form, dispatch, params: { id } } = this.props;
...@@ -18,7 +23,6 @@ class Register extends React.Component { ...@@ -18,7 +23,6 @@ class Register extends React.Component {
const { email, username, nickname, password, confirm } = values; const { email, username, nickname, password, confirm } = values;
dispatch({ type: 'auth/register', payload: { email, username, nickname, password } }); dispatch({ type: 'auth/register', payload: { email, username, nickname, password } });
} }
}); });
...@@ -28,7 +32,7 @@ class Register extends React.Component { ...@@ -28,7 +32,7 @@ class Register extends React.Component {
checkPassword = (rule, value, callback) => { checkPassword = (rule, value, callback) => {
const form = this.props.form; const form = this.props.form;
if (value && value !== form.getFieldValue('password')) { if (value && value !== form.getFieldValue('password')) {
callback('两次密码输入不符'); callback(this.context.intl.messages['Incorrect password.2']);
} else { } else {
callback(); callback();
} }
...@@ -43,9 +47,10 @@ class Register extends React.Component { ...@@ -43,9 +47,10 @@ class Register extends React.Component {
}; };
render() { render() {
const { dispatch, register, form, checkEmail, checkUsername, isEmailExists, isUserNameExists, isRegisterSubmit } = this.props; const { dispatch, register, form, checkEmail, checkUsername, isEmailExists, isUserNameExists, isRegisterSubmit, } = this.props;
const { getFieldDecorator, } = form; const { getFieldDecorator, } = form;
const { email = {}, username = {}, password = {} } = register; const { email = {}, username = {}, password = {} } = register;
const { intl: { messages } } = this.context;
const emailProps = { const emailProps = {
hasFeedback: true, hasFeedback: true,
...@@ -55,7 +60,7 @@ class Register extends React.Component { ...@@ -55,7 +60,7 @@ class Register extends React.Component {
const emailInputProps = { const emailInputProps = {
onBlur: () => dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue() } }), onBlur: () => dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue() } }),
placeholder: 'Email', placeholder: messages.email,
}; };
const usernameProps = { const usernameProps = {
...@@ -66,7 +71,7 @@ class Register extends React.Component { ...@@ -66,7 +71,7 @@ class Register extends React.Component {
const usernameInputProps = { const usernameInputProps = {
onBlur: () => dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue() } }), onBlur: () => dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue() } }),
placeholder: 'Username', placeholder: messages.username,
}; };
return ( return (
...@@ -77,7 +82,7 @@ class Register extends React.Component { ...@@ -77,7 +82,7 @@ class Register extends React.Component {
{getFieldDecorator('email', { {getFieldDecorator('email', {
rules: [{ rules: [{
required: true, required: true,
message: '邮箱格式不对!', message: messages['Please use a correct E-Mail address.'],
pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
}], }],
}, {})( }, {})(
...@@ -89,7 +94,7 @@ class Register extends React.Component { ...@@ -89,7 +94,7 @@ class Register extends React.Component {
{getFieldDecorator('username', { {getFieldDecorator('username', {
rules: [{ rules: [{
required: true, required: true,
message: '用户名格式有误!', message: messages['You can not use this username.'],
pattern: /^[A-Za-z0-9_\u4E00-\u9FD5\u3400-\u4DBF\u{20000}-\u{2A6DF}\u{2A700}-\u{2CEAF}\uF900–\uFAFF\u{2F800}-\u{2FA1D}\uAC00–\uD7AF\u3040-\u30FF\u31F0–\u31FF\u{1B000}–\u{1B0FF}\u3005]+$/u, pattern: /^[A-Za-z0-9_\u4E00-\u9FD5\u3400-\u4DBF\u{20000}-\u{2A6DF}\u{2A700}-\u{2CEAF}\uF900–\uFAFF\u{2F800}-\u{2FA1D}\uAC00–\uD7AF\u3040-\u30FF\u31F0–\u31FF\u{1B000}–\u{1B0FF}\u3005]+$/u,
}], }],
}, {})( }, {})(
...@@ -99,7 +104,7 @@ class Register extends React.Component { ...@@ -99,7 +104,7 @@ class Register extends React.Component {
<FormItem > <FormItem >
{getFieldDecorator('nickname', {})( {getFieldDecorator('nickname', {})(
<Input placeholder="nickname[optional]"/>, <Input placeholder={messages.nickname} />,
)} )}
</FormItem> </FormItem>
...@@ -112,7 +117,7 @@ class Register extends React.Component { ...@@ -112,7 +117,7 @@ class Register extends React.Component {
<Input <Input
prefix={<Icon type="lock" style={{ fontSize: 13 }}/>} prefix={<Icon type="lock" style={{ fontSize: 13 }}/>}
type="password" type="password"
placeholder="Password"/>, placeholder={messages.password}/>,
)} )}
</FormItem> </FormItem>
...@@ -128,14 +133,14 @@ class Register extends React.Component { ...@@ -128,14 +133,14 @@ class Register extends React.Component {
prefix={<Icon type="lock" style={{ fontSize: 13 }}/>} prefix={<Icon type="lock" style={{ fontSize: 13 }}/>}
type="password" type="password"
onBlur={this.handleConfirmBlur} onBlur={this.handleConfirmBlur}
placeholder="Password Again"/>, placeholder={messages['password-again']}/>,
)} )}
</FormItem> </FormItem>
<Button type="primary" htmlType="submit" className="login-form-button"> <Button type="primary" htmlType="submit" className="login-form-button">
Register <Format id={'register'} />
</Button> </Button>
Or <Link to="/login">Sign in!</Link> Or <Link to="/login"><Format id={'login'} /></Link>
</Form> </Form>
</Spin> </Spin>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment