feat: Views localization

This commit is contained in:
NGPixel
2017-05-02 21:41:22 -04:00
parent ea2d98c9b6
commit 40c4ff80f4
19 changed files with 128 additions and 69 deletions

View File

@@ -155,7 +155,7 @@ module.exports = {
return false
}
}).catch((err) => { // eslint-disable-line handle-callback-err
throw new Promise.OperationalError('Entry ' + entryPath + ' does not exist!')
throw new Promise.OperationalError(lang.t('errors:notexist', { path: entryPath }))
})
},
@@ -184,11 +184,11 @@ module.exports = {
}
})
} else {
return Promise.reject(new Error('Parent entry is not a valid file.'))
return Promise.reject(new Error(lang.t('errors:parentinvalid')))
}
})
} else {
return Promise.reject(new Error('Parent entry is root.'))
return Promise.reject(new Error(lang.t('errors:parentisroot')))
}
},
@@ -212,11 +212,11 @@ module.exports = {
})
})
} else {
return Promise.reject(new Error('Entry does not exist!'))
return Promise.reject(new Error(lang.t('errors:notexist', { path: entryPath }))
}
}).catch((err) => {
winston.error(err)
return Promise.reject(new Error('Failed to save document.'))
return Promise.reject(new Error(lang.t('errors:savefailed')))
})
},
@@ -316,11 +316,11 @@ module.exports = {
})
})
} else {
return Promise.reject(new Error('Entry already exists!'))
return Promise.reject(new Error(lang.t('errors:alreadyexists')))
}
}).catch((err) => {
winston.error(err)
return Promise.reject(new Error('Something went wrong.'))
return Promise.reject(new Error(lang.t('errors:generic')))
})
},
@@ -352,7 +352,7 @@ module.exports = {
let self = this
if (_.isEmpty(entryPath) || entryPath === 'home') {
return Promise.reject(new Error('Invalid path!'))
return Promise.reject(new Error(lang.t('errors:invalidpath')))
}
return git.moveDocument(entryPath, newEntryPath).then(() => {

View File

@@ -206,7 +206,7 @@ module.exports = {
let out = cProc.stdout.toString()
return _.includes(out, gitFilePath)
}).then((isTracked) => {
commitMsg = (isTracked) ? 'Updated ' + gitFilePath : 'Added ' + gitFilePath
commitMsg = (isTracked) ? lang.t('git:updated', { path: gitFilePath }) : lang.t('git:added', { path: gitFilePath })
return self._git.add(gitFilePath)
}).then(() => {
let commitUsr = securityHelper.sanitizeCommitUser(author)

View File

@@ -163,7 +163,7 @@ module.exports = {
let fpath = path.resolve(this._uploadsPath, fld, f)
return fs.statAsync(fpath).then((s) => {
throw new Error('File ' + f + ' already exists.')
throw new Error(lang.t('errors:fileexists', { path: f }))
}).catch((err) => {
if (err.code === 'ENOENT') {
return f

View File

@@ -59,14 +59,14 @@ module.exports = {
return self.processFile(pInfo.folder, pInfo.filename).then((mData) => {
return db.UplFile.findByIdAndUpdate(mData._id, mData, { upsert: true })
}).then(() => {
return git.commitUploads('Uploaded ' + p)
return git.commitUploads(lang.t('git:uploaded', { path: p }))
})
})
// -> Remove upload file
self._watcher.on('unlink', (p) => {
return git.commitUploads('Deleted/Renamed ' + p)
return git.commitUploads(lang.t('git:deleted', { path: p }))
})
},

View File

@@ -168,7 +168,7 @@ module.exports = {
return upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
if (!destFolderPath) {
return Promise.reject(new Error('Invalid Folder'))
return Promise.reject(new Error(lang.t('errors:invalidfolder')))
}
return lcdata.validateUploadsFilename(fUrlFilename, destFolder).then((destFilename) => {
@@ -192,7 +192,7 @@ module.exports = {
rq.abort()
destFileStream.destroy()
fs.remove(destFilePath)
reject(new Error('Remote file is too large!'))
reject(new Error(lang.t('errors:remotetoolarge')))
}
}).on('error', (err) => {
destFileStream.destroy()
@@ -243,7 +243,7 @@ module.exports = {
// -> Check for invalid operations
if (sourceFilePath === destFilePath) {
return Promise.reject(new Error('Invalid Operation!'))
return Promise.reject(new Error(lang.t('errors:invalidoperation')))
}
// -> Delete DB entry
@@ -271,7 +271,7 @@ module.exports = {
})
})
} else {
return Promise.reject(new Error('Invalid Destination Folder'))
return Promise.reject(new Error(lang.t('errors:invaliddestfolder')))
}
})
}