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}`]
|
||||
if (translationChunkCell) {
|
||||
lastTranslationChunkId = translationChunkCell.v
|
||||
const translatedText = sheet[`C${i}`].v
|
||||
const translatedCell = sheet[`C${i}`]
|
||||
|
||||
if (translatedText) {
|
||||
console.log("Text: ", translatedText)
|
||||
console.log("Chunk Id: ", lastTranslationChunkId)
|
||||
// TODO: Get translationChunk and create translation...
|
||||
const translationChunk = await db.TranslationChunk.findByPk(lastTranslationChunkId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChunk.Translation
|
||||
}
|
||||
]
|
||||
})
|
||||
if (translatedCell) {
|
||||
const translatedText = translatedCell.v
|
||||
|
||||
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()
|
||||
if (translatedText) {
|
||||
// TODO: Get translationChunk and create translation...
|
||||
const translationChunk = await db.TranslationChunk.findByPk(lastTranslationChunkId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChunk.Translation
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
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++
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user