Bug fix for import translations on blanks
This commit is contained in:
@@ -1482,41 +1482,47 @@ module.exports = function (options) {
|
|||||||
const translationChunkCell = sheet[`D${i}`]
|
const translationChunkCell = sheet[`D${i}`]
|
||||||
if (translationChunkCell) {
|
if (translationChunkCell) {
|
||||||
lastTranslationChunkId = translationChunkCell.v
|
lastTranslationChunkId = translationChunkCell.v
|
||||||
const translatedText = sheet[`C${i}`].v
|
const translatedCell = sheet[`C${i}`]
|
||||||
|
|
||||||
if (translatedText) {
|
if (translatedCell) {
|
||||||
console.log("Text: ", translatedText)
|
const translatedText = translatedCell.v
|
||||||
console.log("Chunk Id: ", lastTranslationChunkId)
|
|
||||||
// TODO: Get translationChunk and create translation...
|
|
||||||
const translationChunk = await db.TranslationChunk.findByPk(lastTranslationChunkId, {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
association: db.TranslationChunk.Translation
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
if (translationChunk) {
|
if (translatedText) {
|
||||||
// Create or update translation
|
// TODO: Get translationChunk and create translation...
|
||||||
if (translationChunk.translation) {
|
const translationChunk = await db.TranslationChunk.findByPk(lastTranslationChunkId, {
|
||||||
// Update translation
|
include: [
|
||||||
if (translationChunk.translation.text != translatedText) {
|
{
|
||||||
translationChunk.translation.text = translatedText
|
association: db.TranslationChunk.Translation
|
||||||
// TODO: Update who made the update??
|
}
|
||||||
await translationChunk.translation.save()
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
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 {
|
|
||||||
// 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user