11import PropTypes from 'prop-types' ;
22import React from 'react' ;
3-
43import Button from '../../../common/Button' ;
54import { PlusIcon } from '../../../common/icons' ;
65import CopyableInput from '../../IDE/components/CopyableInput' ;
@@ -12,7 +11,7 @@ export const APIKeyPropType = PropTypes.shape({
1211 token : PropTypes . object ,
1312 label : PropTypes . string . isRequired ,
1413 createdAt : PropTypes . string . isRequired ,
15- lastUsedAt : PropTypes . string ,
14+ lastUsedAt : PropTypes . string
1615} ) ;
1716
1817class APIKeyForm extends React . Component {
@@ -39,7 +38,7 @@ class APIKeyForm extends React.Component {
3938 }
4039
4140 removeKey ( key ) {
42- const message = `Are you sure you want to delete " ${ key . label } "?` ;
41+ const message = this . props . t ( 'APIKeyForm.ConfirmDelete' , { key_label : key . label } ) ;
4342
4443 if ( window . confirm ( message ) ) {
4544 this . props . removeApiKey ( key . id ) ;
@@ -51,10 +50,10 @@ class APIKeyForm extends React.Component {
5150
5251 if ( hasApiKeys ) {
5352 return (
54- < APIKeyList apiKeys = { this . props . apiKeys } onRemove = { this . removeKey } />
53+ < APIKeyList apiKeys = { this . props . apiKeys } onRemove = { this . removeKey } t = { this . props . t } />
5554 ) ;
5655 }
57- return < p > You have no exsiting tokens. </ p > ;
56+ return < p > { this . props . t ( 'APIKeyForm.NoTokens' ) } </ p > ;
5857 }
5958
6059 render ( ) {
@@ -63,20 +62,18 @@ class APIKeyForm extends React.Component {
6362 return (
6463 < div className = "api-key-form" >
6564 < p className = "api-key-form__summary" >
66- Personal Access Tokens act like your password to allow automated
67- scripts to access the Editor API. Create a token for each script
68- that needs access.
65+ { this . props . t ( 'APIKeyForm.Summary' ) }
6966 </ p >
7067
7168 < div className = "api-key-form__section" >
72- < h3 className = "api-key-form__title" > Create new token </ h3 >
69+ < h3 className = "api-key-form__title" > { this . props . t ( 'APIKeyForm.CreateToken' ) } </ h3 >
7370 < form className = "form form--inline" onSubmit = { this . addKey } >
74- < label htmlFor = "keyLabel" className = "form__label form__label--hidden " > What is this token for? </ label >
71+ < label htmlFor = "keyLabel" className = "form__label form__label--hidden " > { this . props . t ( 'APIKeyForm.TokenLabel' ) } </ label >
7572 < input
7673 className = "form__input"
7774 id = "keyLabel"
7875 onChange = { ( event ) => { this . setState ( { keyLabel : event . target . value } ) ; } }
79- placeholder = "What is this token for? e.g. Example import script"
76+ placeholder = { this . props . t ( 'APIKeyForm.TokenPlaceholder' ) }
8077 type = "text"
8178 value = { this . state . keyLabel }
8279 />
@@ -86,17 +83,16 @@ class APIKeyForm extends React.Component {
8683 label = "Create new key"
8784 type = "submit"
8885 >
89- Create
86+ { this . props . t ( 'APIKeyForm.CreateTokenSubmit' ) }
9087 </ Button >
9188 </ form >
9289
9390 {
9491 keyWithToken && (
9592 < div className = "api-key-form__new-token" >
96- < h4 className = "api-key-form__new-token__title" > Your new access token </ h4 >
93+ < h4 className = "api-key-form__new-token__title" > { this . props . t ( 'APIKeyForm.NewTokenTitle' ) } </ h4 >
9794 < p className = "api-key-form__new-token__info" >
98- Make sure to copy your new personal access token now.
99- You won’t be able to see it again!
95+ { this . props . t ( 'APIKeyForm.NewTokenInfo' ) }
10096 </ p >
10197 < CopyableInput label = { keyWithToken . label } value = { keyWithToken . token } />
10298 </ div >
@@ -105,7 +101,7 @@ class APIKeyForm extends React.Component {
105101 </ div >
106102
107103 < div className = "api-key-form__section" >
108- < h3 className = "api-key-form__title" > Existing tokens </ h3 >
104+ < h3 className = "api-key-form__title" > { this . props . t ( 'APIKeyForm.ExistingTokensTitle' ) } </ h3 >
109105 { this . renderApiKeys ( ) }
110106 </ div >
111107 </ div >
@@ -117,6 +113,7 @@ APIKeyForm.propTypes = {
117113 apiKeys : PropTypes . arrayOf ( PropTypes . shape ( APIKeyPropType ) ) . isRequired ,
118114 createApiKey : PropTypes . func . isRequired ,
119115 removeApiKey : PropTypes . func . isRequired ,
116+ t : PropTypes . func . isRequired
120117} ;
121118
122119export default APIKeyForm ;
0 commit comments