More mantra things
This commit is contained in:
@@ -1569,65 +1569,73 @@ module.exports = function (options) {
|
||||
for (const sheetName in workbook.Sheets) {
|
||||
const sheet = workbook.Sheets[sheetName];
|
||||
|
||||
const artifactVersionId = sheet["D4"].v
|
||||
const translationArtifactVersionId = sheet["E4"].v
|
||||
if (sheet["E4"]) {
|
||||
const translationArtifactVersionId = sheet["E4"].v
|
||||
|
||||
var lastTranslationChunkId = null
|
||||
var i = 6
|
||||
do {
|
||||
lastTranslationChunkId = null
|
||||
const translationChunkCell = sheet[`D${i}`]
|
||||
if (translationChunkCell) {
|
||||
lastTranslationChunkId = translationChunkCell.v
|
||||
const translatedCell = sheet[`C${i}`]
|
||||
var lastTranslationChunkId = null
|
||||
var i = 6
|
||||
do {
|
||||
lastTranslationChunkId = null
|
||||
const translationChunkCell = sheet[`D${i}`]
|
||||
if (translationChunkCell) {
|
||||
lastTranslationChunkId = translationChunkCell.v
|
||||
const translatedCell = sheet[`C${i}`]
|
||||
|
||||
if (translatedCell) {
|
||||
const translatedText = translatedCell.v
|
||||
if (translatedCell) {
|
||||
const translatedText = translatedCell.v
|
||||
|
||||
if (translatedText) {
|
||||
// TODO: Get translationChunk and create translation...
|
||||
const translationChunk = await db.TranslationChunk.findByPk(lastTranslationChunkId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChunk.Translation
|
||||
if (translatedText) {
|
||||
// TODO: Get translationChunk and create translation...
|
||||
const translationChunk = await db.TranslationChunk.findByPk(lastTranslationChunkId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChunk.Translation
|
||||
}
|
||||
]
|
||||
}).catch(error => {
|
||||
console.error("Couldn't process: ",translationChunkCell);
|
||||
console.error(`Error ${lastTranslationChunkId}: `, error);
|
||||
return null;
|
||||
})
|
||||
|
||||
if (translationChunk) {
|
||||
// Create or update translation
|
||||
if (translationChunk.translation) {
|
||||
// Update translation
|
||||
if (translationChunk.translation.text != translatedText) {
|
||||
translationChunk.translation.text = translatedText
|
||||
// TODO: Update who made the update??
|
||||
await translationChunk.translation.save()
|
||||
}
|
||||
} else {
|
||||
// Create translation for this chunk
|
||||
const translation = await db.Translation.create({
|
||||
creatorId: request.user.id,
|
||||
translationChunkId: translationChunk.id,
|
||||
text: translatedText,
|
||||
translationArtifactVersionId: translationArtifactVersionId
|
||||
})
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
if (translationChunk) {
|
||||
// Create or update translation
|
||||
if (translationChunk.translation) {
|
||||
// Update translation
|
||||
if (translationChunk.translation.text != translatedText) {
|
||||
translationChunk.translation.text = translatedText
|
||||
// TODO: Update who made the update??
|
||||
await translationChunk.translation.save()
|
||||
}
|
||||
} else {
|
||||
// Create translation for this chunk
|
||||
const translation = await db.Translation.create({
|
||||
creatorId: request.user.id,
|
||||
translationChunkId: translationChunk.id,
|
||||
text: translatedText,
|
||||
translationArtifactVersionId: translationArtifactVersionId
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(`${sheetName}: Couldn't find a translated cell C${i}: `, translatedCell)
|
||||
console.log("Chunk Id: ", lastTranslationChunkId)
|
||||
}
|
||||
} else {
|
||||
console.log(`${sheetName}: Couldn't find a translated cell C${i}: `, translatedCell)
|
||||
console.log("Chunk Id: ", lastTranslationChunkId)
|
||||
|
||||
|
||||
i++
|
||||
}
|
||||
|
||||
|
||||
i++
|
||||
}
|
||||
} while (lastTranslationChunkId);
|
||||
|
||||
} while (lastTranslationChunkId);
|
||||
|
||||
// Chunks...
|
||||
// Chunks...
|
||||
|
||||
console.log("Done processing all...")
|
||||
console.log("Done processing all...")
|
||||
} else {
|
||||
console.log("Couldn't process sheet: ", sheetName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
response.redirect(`/projects/${project.id}`)
|
||||
|
||||
@@ -320,7 +320,7 @@ module.exports = function (options) {
|
||||
}).then(translationChapter => {
|
||||
if (translationChapter) {
|
||||
response.contentType = "text/plain"
|
||||
response.send(markdownProducer.produceMarkdownString(tokens))
|
||||
response.send(markdownProducer.produceMarkdownString(translationChapter))
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user