Commit e99aece6 authored by 2breakegg's avatar 2breakegg

i18n

parent f9c4e7cd
This diff is collapsed.
{
"en": {
"language": "中文",
"l": "zh-CN",
"MoeCube":"MoeCube",
"username": "User Name",
"email": "E-Mail",
"password": "Password",
......@@ -20,6 +19,7 @@
"yonghuan": "The Disappearing of Gensokyo",
"sign-up": "Sign Up",
"sign-in": "Sign In",
"Please-sign-in":"Please sign In",
"email-address-or-username": "E-Mail or Username",
"register-now": "register-now!",
"register":"register",
......@@ -29,31 +29,19 @@
"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.",
"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.",
"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-correct.": "Password is correct.",
"Incorrect-password.2": "Incorrect password.",
"The-E-Mail-has-been-sent.": "The E-Mail has been sent.",
"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. ",
"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",
......@@ -65,28 +53,33 @@
"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!",
"Please-input-your-Password!":"Please input your Password!",
"verify-email":"verify email",
"verify-email":"Verify email",
"account-info":"Account Info",
"reset-username":"Reset Username",
"reset-email":"Reset Email",
"reset-password":"Reset Password",
"old-password":"old password",
"new-password":"new password",
"Password length must be between 8 and 24 characters":"Password length must be between 8 and 24 characters",
"i_update_success": "Update Success!",
"Password-length-must-be-between-8-and-24-characters.":"Password length must be between 8 and 24 characters.",
"email_exists":"email exists",
"update_success": "Update Success!",
"i_password_error": "Incorrect password. ",
"i_user_unexists":"",
"i_user_unexists":"User does not exisit.",
"i_email_exists":"email is exists",
"i_username_exists":"",
"i_not_found":"",
"i_key_out_time":"",
"i_username_exists":"username is exists",
"i_not_found":"user unexists",
"i_key_time_out":"url is time out",
"i_key_invalid":"url is invalid",
"A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.":"A verification email has been sent to you, please check the mail to complete.",
"没毛用":"防逗号报错,上线删"
},
"zh": {
"language": "english",
"l": "en-US",
"MoeCube":"萌立方",
"username": "用户名",
"email": "邮箱",
"password": "密码",
......@@ -105,6 +98,7 @@
"yonghuan": "永远消失的幻想乡",
"sign-up": "注册",
"sign-in": "登陆",
"Please-sign-in":"您尚未登录,请先登录",
"email-address-or-username": "邮箱或用户名",
"register-now": "现在注册",
"register":"注册",
......@@ -114,31 +108,21 @@
"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.": "邮件已发送",
"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-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.": "用户名可以使用",
"User does not exisit.": "用户不存在",
"Incorrect password.": "密码不正确",
"Please check your registration info again.": "请填写正确的注册信息。",
"Your account has not been verified.": "您的账户还未完成验证,请查看激活邮件,激活后即可登陆。",
"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.": "您的账号已经创建。您将会收到一封验证邮件,请查看邮件完成注册。",
"Your-account-has-been-created.": "您的账号已经创建。您将会收到一封验证邮件,请查看邮件完成注册。",
"Error": "出问题了",
"Your account has been successfully activated!": "账号激活成功!",
"close": "关闭",
......@@ -150,7 +134,7 @@
"Your email has been updated.": "邮箱已经更新,您将会收到一封验证邮件,请您查看Email完成验证。",
"Please input your account!":"请填写你的邮箱或用户名!",
"Please input your Password!":"请填写你的密码!",
"Please-input-your-Password!":"请填写你的密码!",
"verify-email":"验证邮箱",
"account-info":"账户信息",
......@@ -159,11 +143,24 @@
"reset-password":"修改密码",
"old-password":"原密码",
"new-password":"新密码",
"Password length must be between 8 and 24 characters":"密码必须为8-24位",
"Please confirm your password":"",
"Password-length-must-be-between-8-and-24-characters.":"密码必须为8-24位",
"email_exists":"邮箱已存在",
"update_success": "修改成功",
"i_password_error": "密码错误",
"i_user_unexists":"用户不存在",
"i_email_exists":"邮箱已存在",
"i_username_exists":"用户名已存在",
"i_not_found":"用户不存在",
"i_key_time_out":"此链接已过期",
"i_key_invalid":"此链接已失效",
"A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.":"一封验证邮件已经发送给您,请查看邮件完成修改。",
"原_验证邮件已发送":"邮件已发送,验证邮箱后,完成修改邮箱",
"密码至少为8-24位":"密码至少为8-24位",
"没毛用":"防逗号报错,上线删"
}
......
......@@ -62,7 +62,7 @@ class EmailForm extends React.Component {
},
decorator: {
rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }
{ required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/ }
]
},
input: {
......
......@@ -21,8 +21,9 @@ class EmailForm extends React.Component {
}
checkPassword = (rule, value, callback) => {
const form = this.props.form;
const { intl: { messages } } = this.context;
if (value && value !== form.getFieldValue('new_password')) {
callback('两次密码输入不符');
callback(messages['Incorrect-password.2']);
} else {
callback();
}
......@@ -64,7 +65,7 @@ class EmailForm extends React.Component {
},
decorator: {
rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ },
{ required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/ },
{ validator: this.checkConfirm }
],
},
......@@ -85,7 +86,7 @@ class EmailForm extends React.Component {
},
decorator: {
rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/},
{ required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/},
{ validator: this.checkPassword}
],
},
......
......@@ -62,7 +62,7 @@ class EmailForm extends React.Component {
},
decorator: {
rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }
{ required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/ }
]
},
input: {
......
......@@ -61,7 +61,7 @@ class EmailForm extends React.Component {
},
decorator: {
rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ },
{ required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/ },
],
},
input: {
......
import { login, forgot, register, reset, activate, checkUserExists } from '../services/auth'
import { message } from 'antd'
import { routerRedux } from 'dva/router'
import { message } from 'antd';
import { routerRedux } from 'dva/router';
import { activate, checkUserExists, forgot, login, register, reset } from '../services/auth';
export default {
namespace: 'auth',
state: {
input:{},
input: {},
activateState: false,
checkEmail: '',
checkUsername: '',
......@@ -19,7 +18,7 @@ export default {
isForgotSubmit: false,
isSpinSubmit: false,
isActivateSubmit: false,
register: {}
register: {},
},
reducers: {
change(state, action) {
......@@ -105,133 +104,137 @@ export default {
forgotSuccess(state, action) {
return {
...state, ...{
isForgotSubmit: false
}
isForgotSubmit: false,
}
};
},
forgotFail(state, action) {
return {
...state, ...{
isForgotSubmit: false
}
isForgotSubmit: false,
}
};
},
reset(state, action) {
return {
...state, ...{
isResetSubmit: true
}
isResetSubmit: true,
}
};
},
resetSuccess(state, action) {
return {
...state, ...{
isResetSubmit: false
}
isResetSubmit: false,
}
};
},
resetFail(state, action) {
return {
...state, ...{
isResetSubmit: false
}
isResetSubmit: false,
}
};
},
},
effects: {
*activate({ payload }, { call, put }) {
*activate({ payload }, { call, put, select }) {
const { messages } = yield select(state => state.common);
try {
const { data } = yield call(activate, payload)
if(data) {
message.success("激活成功")
const { data } = yield call(activate, payload);
if (data) {
message.success(messages['Your account has been successfully activated!'], 5);
}
} catch (error) {
message.error(error.message)
message.error(error.message);
}
},
*checkEmail({ payload }, { call, put }) {
if(!payload.email){
yield put({ type: 'check', payload: { checkEmail: 'error' } })
return
if (!payload.email) {
yield put({ type: 'check', payload: { checkEmail: 'error' } });
return;
}
try {
const { data } = yield call(checkUserExists, {email: payload.email})
const { data } = yield call(checkUserExists, { email: payload.email });
if (data) {
yield put({ type: 'check', payload: { isEmailExists: true, checkEmail: 'warning' } })
yield put({ type: 'check', payload: { isEmailExists: true, checkEmail: 'warning' } });
}
} catch (error) {
yield put({ type: 'check', payload: { isEmailExists: false, checkEmail: 'success' } })
yield put({ type: 'check', payload: { isEmailExists: false, checkEmail: 'success' } });
}
},
*checkUsername({ payload }, { call, put }) {
if(!payload.username){
yield put({ type: 'check', payload: { checkUsername: 'error' } })
return
if (!payload.username) {
yield put({ type: 'check', payload: { checkUsername: 'error' } });
return;
}
try {
const { data } = yield call(checkUserExists, { username: payload.username})
const { data } = yield call(checkUserExists, { username: payload.username });
if (data) {
yield put({ type: 'check', payload: { isUserNameExists: true, checkUsername: 'warning' } })
yield put({ type: 'check', payload: { isUserNameExists: true, checkUsername: 'warning' } });
}
} catch (error) {
yield put({ type: 'check', payload: { isUserNameExists: false, checkUsername: 'success' } })
yield put({ type: 'check', payload: { isUserNameExists: false, checkUsername: 'success' } });
}
},
*login({ payload }, { call, put, select }) {
const { messages } = yield select(state => state.common)
const { messages } = yield select(state => state.common);
try {
const { data } = yield call(login, payload)
const { data } = yield call(login, payload);
if (data) {
yield put({ type: 'loginSuccess', payload: { input: payload } })
yield put({ type: 'user/loginSuccess', payload: { data } })
yield put({ type: 'loginSuccess', payload: { input: payload } });
yield put({ type: 'user/loginSuccess', payload: { data } });
}
} catch (error) {
yield put({ type: 'loginFail' })
message.error(messages[error.message])
yield put({ type: 'loginFail' });
message.error(messages[error.message]);
}
},
*forgot({ payload }, { call, put }) {
*forgot({ payload }, { call, put, select }) {
const { messages } = yield select(state => state.common);
try {
const { data } = yield call(forgot, payload)
if(data){
yield put({ type: 'forgotSuccess' })
message.info("已发送密码重置邮件", 3)
const { data } = yield call(forgot, payload);
if (data) {
yield put({ type: 'forgotSuccess' });
message.info(messages['A password reset email has been sent to you.'], 5);
}
} catch (error) {
yield put({ type: 'forgotFail' })
message.error(error.message)
yield put({ type: 'forgotFail' });
message.error(messages[error.message], 3);
}
},
*register({ payload }, { call, put }) {
*register({ payload }, { call, put, select }) {
const { messages } = yield select(state => state.common);
try {
const { data } = yield call(register, payload)
const { data } = yield call(register, payload);
if (data) {
yield put({ type: 'registerSuccess' })
yield put({ type: 'registerSuccess' });
yield put({ type: 'user/loginSuccess', payload: { data } })
yield put({ type: 'loginSuccess', payload: { input: payload } })
message.info("注册成功, 请验证激活邮件~", 3)
yield put(routerRedux.replace("/verify"))
yield put({ type: 'user/loginSuccess', payload: { data } });
yield put({ type: 'loginSuccess', payload: { input: payload } });
message.info(messages['Your account has been created.'], 5);
yield put(routerRedux.replace('/verify'));
}
} catch (error) {
yield put({ type: 'registerFail' })
message.error(error.message, 3)
yield put({ type: 'registerFail' });
message.error(messages[error.message], 3);
}
},
*reset({ payload }, { call, put }) {
*reset({ payload }, { call, put, select }) {
const { messages } = yield select(state => state.common);
try {
const { data } = yield call(reset, payload)
const { data } = yield call(reset, payload);
if (data) {
yield put({ type: 'resetSuccess' })
message.info("重置成功")
yield put({ type: 'resetSuccess' });
message.info(messages.update_success, 3);
}
} catch (error) {
yield put({ type: 'resetFail' })
message.error(error.message, 3)
yield put({ type: 'resetFail' });
message.error(messages[error.message], 3);
}
},
},
......
......@@ -110,7 +110,7 @@ export default {
}
}
} catch (error) {
message.error("自动登录失败")
message.error(error.message)
}
},
*updateProfile({ payload }, { call, put, select }) {
......@@ -124,23 +124,22 @@ export default {
if (data) {
yield put({ type: 'updateProfileSuccess', payload: { user: data, token } })
message.info(messages["i_update_success"])
message.info(messages["update_success"])
}
} catch (error) {
yield put({ type: 'updateProfileFail' })
message.error(messages[error.message])
message.error(error.message)
}
},
*updateEmail({ payload }, { call, put, select }) {
let { messages } = yield select(state => state.common)
try {
let token = yield select(state => state.user.token)
let { messages } = yield select(state => state.common)
let { data } = yield call(updateAccount, {...payload, token})
if (data) {
yield put({ type: 'updateAccountSuccess', payload: { user: data, token } })
message.info("验证邮件已发送")
message.info(messages['A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.'])
}
} catch (error) {
yield put({ type: 'updateAccountFail' })
......@@ -149,16 +148,14 @@ export default {
},
*updateAccount({ payload }, { call, put, select }) {
let { messages } = yield select(state => state.common)
try {
let token = yield select(state => state.user.token)
let { messages } = yield select(state => state.common)
let { data } = yield call(updateAccount, {...payload, token})
if (data) {
yield put({ type: 'updateAccountSuccess', payload: { user: data, token } })
message.info(messages["i_update_success"])
message.info(messages["update_success"])
}
} catch (error) {
yield put({ type: 'updateAccountFail' })
......
......@@ -47,7 +47,7 @@ class Login extends React.Component {
</FormItem>
<FormItem>
{getFieldDecorator('password', {
rules: [{ required: true, message: messages['Please input your Password!'] }],
rules: [{ required: true, message: messages['Please-input-your-Password!'] }],
})(
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder={messages.password} />,
)}
......
......@@ -34,7 +34,7 @@ class Register extends React.Component {
checkPassword = (rule, value, callback) => {
const form = this.props.form;
if (value && value !== form.getFieldValue('password')) {
callback(this.context.intl.messages['Incorrect password.2']);
callback(this.context.intl.messages['Incorrect-password.2']);
} else {
callback();
}
......@@ -90,7 +90,7 @@ class Register extends React.Component {
{getFieldDecorator('email', {
rules: [{
required: true,
message: messages['Please use a correct E-Mail address.'],
message: messages['Please-use-a-correct-E-Mail-address.'],
pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
}],
}, {})(
......@@ -102,7 +102,7 @@ class Register extends React.Component {
{getFieldDecorator('username', {
rules: [{
required: true,
message: messages['You can not use this username.'],
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,
}],
}, {})(
......@@ -112,7 +112,7 @@ class Register extends React.Component {
<FormItem hasFeedback>
{getFieldDecorator('password', {
rules: [{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }],
rules: [{ required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/ }],
}, {
validator: this.checkConfirm,
})(
......@@ -126,7 +126,7 @@ class Register extends React.Component {
<FormItem hasFeedback>
{getFieldDecorator('confirm', {
rules: [{
required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/,
required: true, message: messages['Password-length-must-be-between-8-and-24-characters.'], pattern: /^.{8,24}$/,
}, {
validator: this.checkPassword,
}],
......
......@@ -71,7 +71,7 @@ class Reset extends React.Component {
<FormItem>
{getFieldDecorator('confirm', {
rules: [{
required: true, message: messages['Incorrect password.2'],
required: true, message: messages['Incorrect-password.2'],
}, {
validator: this.checkPassword,
}],
......
import React from 'react';
import React, { PropTypes } from 'react';
import { connect } from 'dva';
import { FormattedMessage as Format } from 'react-intl';
import styles from './Verify.css';
import { Form, Input, Steps, Icon, Spin, Alert, Tag } from 'antd';
import { routerRedux } from 'dva/router'
const FormItem = Form.Item;
import SubmitButton from '../components/SubmitButton'
import SubmitButton from '../components/SubmitButton';
const Step = Steps.Step
class Verify extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
state = {
isChangeEmail: false
}
......@@ -37,23 +41,24 @@ class Verify extends React.Component {
dispatch({ type: 'user/updateEmail', payload: { email, password, user_id: id } });
};
render() {
render(select) {
const { form, dispatch, user, checkEmail, isEmailExists, loading, input } = this.props
const { getFieldDecorator } = form;
const { id, email } = user;
const { intl: { messages } } = this.context
const emailProps = {
fromItem: {
label: "修改邮箱",
label: messages['reset-email'],
hasFeedback: true,
validateStatus: checkEmail,
help: isEmailExists ? 'email exists' : '',
help: isEmailExists ? messages.email_exists : '',
},
decorator: {
initialValue: email
},
input: {
placeholder: "email"
placeholder: messages.email,
}
}
......@@ -63,8 +68,8 @@ class Verify extends React.Component {
<Spin spinning={loading} delay={100}>
<Steps size="large" current={1}>
<Step title="Register" icon={<Icon type="solution" />} />
<Step title="Verify Email" icon={<Icon type="mail" />} />
<Step title={messages['sign-up']} icon={<Icon type="solution" />} />
<Step title={messages['verify-email']} icon={<Icon type="mail" />} />
</Steps>
{id && input["password"] ?
......@@ -72,10 +77,10 @@ class Verify extends React.Component {
style={{ marginTop: '24px' }}
message={
<div>
<span style={{marginRight: '10px'}}>验证邮件已发送,请查收~</span>
<Tag color="blue" onClick={this.onReSend}>重发</Tag>
<span style={{marginRight: '10px'}}><Format id={'Your-account-has-been-created.'} /></span>
<Tag color="blue" onClick={this.onReSend}><Format id={'send-email2'} /></Tag>
<Tag color="orange" onClick={() => this.setState({ isChangeEmail: true })}>
修改邮箱
<Format id={'reset-email'} />
</Tag>
</div>
}
......@@ -87,8 +92,8 @@ class Verify extends React.Component {
style={{ marginTop: '24px' }}
message={
<div>
<span style={{marginRight: '10px'}}>您尚未登录,请先登录</span>
<Tag color="blue" onClick={ () => dispatch(routerRedux.replace("/signin"))}>登录</Tag>
<span style={{marginRight: '10px'}}><Format id={'Please-sign-in'} /></span>
<Tag color="blue" onClick={ () => dispatch(routerRedux.replace("/signin"))}><Format id={'sign-in'} /></Tag>
</div>
}
type="warning"
......
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