@@ -3,6 +3,8 @@ import React from 'react';
33import { bindActionCreators } from 'redux' ;
44import { connect } from 'react-redux' ;
55import classNames from 'classnames' ;
6+ import { withTranslation } from 'react-i18next' ;
7+
68import * as IDEActions from '../actions/ide' ;
79import * as FileActions from '../actions/files' ;
810import DownArrowIcon from '../../../images/down-filled-triangle.svg' ;
@@ -152,7 +154,9 @@ export class FileNode extends React.Component {
152154 }
153155
154156 handleClickDelete = ( ) => {
155- if ( window . confirm ( `Are you sure you want to delete ${ this . props . name } ?` ) ) {
157+ const prompt = this . props . t ( 'Common.DeleteConfirmation' , { name : this . props . name } ) ;
158+
159+ if ( window . confirm ( prompt ) ) {
156160 this . setState ( { isDeleting : true } ) ;
157161 this . props . resetSelectedFile ( this . props . id ) ;
158162 setTimeout ( ( ) => this . props . deleteFile ( this . props . id , this . props . parentId ) , 100 ) ;
@@ -237,6 +241,8 @@ export class FileNode extends React.Component {
237241 const isFolder = this . props . fileType === 'folder' ;
238242 const isRoot = this . props . name === 'root' ;
239243
244+ const { t } = this . props ;
245+
240246 return (
241247 < div className = { itemClass } >
242248 { ! isRoot &&
@@ -252,14 +258,14 @@ export class FileNode extends React.Component {
252258 < button
253259 className = "sidebar__file-item-closed"
254260 onClick = { this . showFolderChildren }
255- aria-label = "Open folder contents"
261+ aria-label = { t ( 'FileNode.OpenFolderARIA' ) }
256262 >
257263 < FolderRightIcon className = "folder-right" focusable = "false" aria-hidden = "true" />
258264 </ button >
259265 < button
260266 className = "sidebar__file-item-open"
261267 onClick = { this . hideFolderChildren }
262- aria-label = "Close file contents"
268+ aria-label = { t ( 'FileNode.CloseFolderARIA' ) }
263269 >
264270 < FolderDownIcon className = "folder-down" focusable = "false" aria-hidden = "true" />
265271 </ button >
@@ -286,7 +292,7 @@ export class FileNode extends React.Component {
286292 />
287293 < button
288294 className = "sidebar__file-item-show-options"
289- aria-label = "Toggle open/close file options"
295+ aria-label = { t ( 'FileNode.ToggleFileOptionsARIA' ) }
290296 ref = { ( element ) => { this [ `fileOptions-${ this . props . id } ` ] = element ; } }
291297 tabIndex = "0"
292298 onClick = { this . toggleFileOptions }
@@ -301,35 +307,35 @@ export class FileNode extends React.Component {
301307 < React . Fragment >
302308 < li >
303309 < button
304- aria-label = "add folder"
310+ aria-label = { t ( 'FileNode.AddFolderARIA' ) }
305311 onClick = { this . handleClickAddFolder }
306312 onBlur = { this . onBlurComponent }
307313 onFocus = { this . onFocusComponent }
308314 className = "sidebar__file-item-option"
309315 >
310- Create folder
316+ { t ( 'FileNode.AddFolder' ) }
311317 </ button >
312318 </ li >
313319 < li >
314320 < button
315- aria-label = "add file"
321+ aria-label = { t ( 'FileNode.AddFileARIA' ) }
316322 onClick = { this . handleClickAddFile }
317323 onBlur = { this . onBlurComponent }
318324 onFocus = { this . onFocusComponent }
319325 className = "sidebar__file-item-option"
320326 >
321- Create file
327+ { t ( 'FileNode.AddFile' ) }
322328 </ button >
323329 </ li >
324330 { this . props . authenticated &&
325331 < li >
326332 < button
327- aria-label = "upload file"
333+ aria-label = { t ( 'FileNode.UploadFileARIA' ) }
328334 onClick = { this . handleClickUploadFile }
329335 onBlur = { this . onBlurComponent }
330336 onFocus = { this . onFocusComponent }
331337 >
332- Upload file
338+ { t ( 'FileNode.UploadFile' ) }
333339 </ button >
334340 </ li >
335341 }
@@ -342,7 +348,7 @@ export class FileNode extends React.Component {
342348 onFocus = { this . onFocusComponent }
343349 className = "sidebar__file-item-option"
344350 >
345- Rename
351+ { t ( 'FileNode. Rename' ) }
346352 </ button >
347353 </ li >
348354 < li >
@@ -352,7 +358,7 @@ export class FileNode extends React.Component {
352358 onFocus = { this . onFocusComponent }
353359 className = "sidebar__file-item-option"
354360 >
355- Delete
361+ { t ( 'FileNode. Delete' ) }
356362 </ button >
357363 </ li >
358364 </ ul >
@@ -388,6 +394,7 @@ FileNode.propTypes = {
388394 canEdit : PropTypes . bool . isRequired ,
389395 openUploadFileModal : PropTypes . func . isRequired ,
390396 authenticated : PropTypes . bool . isRequired ,
397+ t : PropTypes . func . isRequired ,
391398 onClickFile : PropTypes . func
392399} ;
393400
@@ -408,5 +415,8 @@ function mapDispatchToProps(dispatch) {
408415 return bindActionCreators ( Object . assign ( FileActions , IDEActions ) , dispatch ) ;
409416}
410417
411- const ConnectedFileNode = connect ( mapStateToProps , mapDispatchToProps ) ( FileNode ) ;
418+ const TranslatedFileNode = withTranslation ( ) ( FileNode ) ;
419+
420+ const ConnectedFileNode = connect ( mapStateToProps , mapDispatchToProps ) ( TranslatedFileNode ) ;
421+
412422export default ConnectedFileNode ;
0 commit comments