@@ -3,6 +3,8 @@ import React from 'react';
33import { connect } from 'react-redux' ;
44import { bindActionCreators , compose } from 'redux' ;
55import { reduxForm } from 'redux-form' ;
6+ import { withTranslation } from 'react-i18next' ;
7+ import i18n from 'i18next' ;
68import NewFileForm from './NewFileForm' ;
79import { closeNewFileModal } from '../actions/ide' ;
810import { createFile } from '../actions/files' ;
@@ -33,11 +35,11 @@ class NewFileModal extends React.Component {
3335 < section className = "modal" ref = { ( element ) => { this . modal = element ; } } >
3436 < div className = "modal-content" >
3537 < div className = "modal__header" >
36- < h2 className = "modal__title" > Create File </ h2 >
38+ < h2 className = "modal__title" > { this . props . t ( 'NewFileModal.Title' ) } </ h2 >
3739 < button
3840 className = "modal__exit-button"
3941 onClick = { this . props . closeNewFileModal }
40- aria-label = "Close New File Modal"
42+ aria-label = { this . props . t ( 'NewFileModal.CloseButtonARIA' ) }
4143 >
4244 < ExitIcon focusable = "false" aria-hidden = "true" />
4345 </ button >
@@ -54,16 +56,17 @@ class NewFileModal extends React.Component {
5456
5557NewFileModal . propTypes = {
5658 createFile : PropTypes . func . isRequired ,
57- closeNewFileModal : PropTypes . func . isRequired
59+ closeNewFileModal : PropTypes . func . isRequired ,
60+ t : PropTypes . func . isRequired
5861} ;
5962
6063function validate ( formProps ) {
6164 const errors = { } ;
6265
6366 if ( ! formProps . name ) {
64- errors . name = 'Please enter a name' ;
67+ errors . name = i18n . t ( 'NewFileModal.EnterName' ) ;
6568 } else if ( ! formProps . name . match ( CREATE_FILE_REGEX ) ) {
66- errors . name = 'Invalid file type. Valid extensions are .js, .css, .json, .txt, .csv, .tsv, .frag, and .vert.' ;
69+ errors . name = i18n . t ( 'NewFileModal.InvalidType' ) ;
6770 }
6871
6972 return errors ;
@@ -77,11 +80,11 @@ function mapDispatchToProps(dispatch) {
7780 return bindActionCreators ( { createFile, closeNewFileModal } , dispatch ) ;
7881}
7982
80- export default compose (
83+ export default withTranslation ( ) ( compose (
8184 connect ( mapStateToProps , mapDispatchToProps ) ,
8285 reduxForm ( {
8386 form : 'new-file' ,
8487 fields : [ 'name' ] ,
8588 validate
8689 } )
87- ) ( NewFileModal ) ;
90+ ) ( NewFileModal ) ) ;
0 commit comments