@@ -12,6 +12,7 @@ import Button from "../components/Button";
1212import Box from "../components/Box" ;
1313import { NotificationContext } from "../components/Notifications" ;
1414import LoadingContext from "../utils/LoadingContext" ;
15+ import LocaleContext from "../utils/LocaleContext" ;
1516
1617export const usernamePattern = "[A-Za-z0-9.]+" ;
1718
@@ -21,6 +22,7 @@ const Register = ({ token: inviteToken, tokenError }) => {
2122 const { colors } = useContext ( ThemeContext ) ;
2223 const { addNotification } = useContext ( NotificationContext ) ;
2324 const { setLoading } = useContext ( LoadingContext ) ;
25+ const { getLocaleString } = useContext ( LocaleContext ) ;
2426
2527 const router = useRouter ( ) ;
2628
@@ -60,11 +62,17 @@ const Register = ({ token: inviteToken, tokenError }) => {
6062 setCookie ( "userId" , uid , { path : "/" , expires } ) ;
6163 setCookie ( "username" , username , { path : "/" , expires } ) ;
6264
63- addNotification ( "success" , `Welcome ${ form . get ( "username" ) } !` ) ;
65+ addNotification (
66+ "success" ,
67+ `${ getLocaleString ( "welcome" ) } ${ form . get ( "username" ) } !`
68+ ) ;
6469
6570 router . push ( "/" ) ;
6671 } catch ( e ) {
67- addNotification ( "error" , `Could not register: ${ e . message } ` ) ;
72+ addNotification (
73+ "error" ,
74+ `${ getLocaleString ( "registerFailed" ) } : ${ e . message } `
75+ ) ;
6876 console . error ( e ) ;
6977 }
7078
@@ -74,40 +82,46 @@ const Register = ({ token: inviteToken, tokenError }) => {
7482 if ( SQ_ALLOW_REGISTER !== "open" && SQ_ALLOW_REGISTER !== "invite" ) {
7583 return (
7684 < >
77- < SEO title = "Register" />
85+ < SEO title = { getLocaleString ( "register" ) } />
7886 < Text as = "h1" mb = { 5 } >
79- Register
87+ { getLocaleString ( "register" ) }
8088 </ Text >
81- < p > Registration is closed .</ p >
89+ < p > { getLocaleString ( "registrationClosed" ) } .</ p >
8290 </ >
8391 ) ;
8492 }
8593
8694 return (
8795 < >
88- < SEO title = "Register" />
96+ < SEO title = { getLocaleString ( "register" ) } />
8997 < Text as = "h1" mb = { 5 } >
90- Register
98+ { getLocaleString ( "register" ) }
9199 </ Text >
92100 { ! tokenError ? (
93101 < form onSubmit = { handleRegister } >
94- < Input name = "email" type = "email" label = "Email" mb = { 4 } required />
102+ < Input
103+ name = "email"
104+ type = "email"
105+ label = { getLocaleString ( "email" ) }
106+ mb = { 4 }
107+ required
108+ />
95109 < Input
96110 name = "username"
97- label = "Username"
98- placeholder = { `Can only consist of letters, numbers, and “.”` }
111+ label = { getLocaleString ( "username" ) }
112+ placeholder = { getLocaleString ( "usernameRules" ) }
99113 pattern = { usernamePattern }
100114 mb = { 4 }
101115 required
102116 />
103117 < Input
104118 name = "password"
105119 type = "password"
106- label = "Password"
120+ label = { getLocaleString ( "password" ) }
107121 mb = { 4 }
108122 required
109123 />
110- < Button > Register </ Button >
124+ < Button > { getLocaleString ( "register" ) } </ Button >
111125 </ form >
112126 ) : (
113127 < Box
@@ -117,7 +131,9 @@ const Register = ({ token: inviteToken, tokenError }) => {
117131 borderRadius = { 1 }
118132 p = { 4 }
119133 >
120- < Text > Could not register: { tokenError } </ Text >
134+ < Text >
135+ { getLocaleString ( "registerFailed" ) } : { tokenError }
136+ </ Text >
121137 </ Box >
122138 ) }
123139 </ >
0 commit comments