Fix back translate
This commit is contained in:
@@ -63,6 +63,12 @@ module.exports = function (options) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.Dialect
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.BackTranslationFrom
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -258,26 +264,24 @@ module.exports = function (options) {
|
|||||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
association: db.TranslationArtifactVersion.Dialect,
|
||||||
required: true,
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.TranslationChapters,
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.ArtifactVersion.Chapters,
|
association: db.TranslationChapter.TranslationChunks,
|
||||||
required: true,
|
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Chapter.Chunks,
|
association: db.TranslationChunk.Translation,
|
||||||
required: true,
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
association: db.Chunk.Translation,
|
|
||||||
required: true,
|
|
||||||
// TODO: Where text is not null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||||
|
include: [
|
||||||
{
|
{
|
||||||
association: db.ArtifactVersion.Artifact,
|
association: db.ArtifactVersion.Artifact,
|
||||||
include: [
|
include: [
|
||||||
@@ -292,59 +296,34 @@ module.exports = function (options) {
|
|||||||
}).then((translationArtifactVersion) => {
|
}).then((translationArtifactVersion) => {
|
||||||
if (translationArtifactVersion) {
|
if (translationArtifactVersion) {
|
||||||
// TODO: Create a backTranslation...
|
// TODO: Create a backTranslation...
|
||||||
backTranslatedArtifact = {}
|
return db.TranslationArtifactVersion.create({
|
||||||
return db.BackTranslation.create({
|
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
translationArtifactVersionId: translationArtifactVersion.id,
|
name: translationArtifactVersion.artifactVersion.artifact.dialect.name,
|
||||||
artifact: {
|
artifactVersionId: translationArtifactVersion.artifactVersionId,
|
||||||
creatorId: request.user.id,
|
dialectId: translationArtifactVersion.dialect.id,
|
||||||
name: translationArtifactVersion.name + translationArtifactVersion.artifactVersion.artifact.name,
|
backTranslationFromId: translationArtifactVersion.id,
|
||||||
url: `/translate/${request.params.id}`,
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
dialectId: translationArtifactVersion.dialectId,
|
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
||||||
licenseId: "copyright", // Should be closed because it's a back translation not meant to be published
|
return {
|
||||||
artifactVersions: [
|
creatorId: request.user.id,
|
||||||
{
|
chapterId: translationChapter.chapterId,
|
||||||
tag: translationArtifactVersion.artifactVersion.tag,
|
translationChunks: translationChapter.translationChunks.map(translationChunk => {
|
||||||
chapters: translationArtifactVersion.artifactVersion.chapters.map(chapter => {
|
return {
|
||||||
return {
|
creatorId: request.user.id,
|
||||||
name: chapter.chunks[0].translation.text, // TODO: This isn't important...
|
chunkId: translationChunk.chunkId,
|
||||||
chunks: chapter.chunks.map(chunk => {
|
text: translationChunk.translation.text,
|
||||||
return {
|
index: translationChunk.index
|
||||||
text: chunk.translation.text,
|
}
|
||||||
index: chunk.index
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}),
|
|
||||||
translationArtifactVersions: [
|
|
||||||
{
|
|
||||||
dialectId: translationArtifactVersion.artifactVersion.artifact.dialect.id,
|
|
||||||
name: translationArtifactVersion.artifactVersion.artifact.dialect.name
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.BackTranslation.Artifact,
|
association: db.TranslationArtifactVersion.TranslationChapters,
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Artifact.ArtifactVersions,
|
association: db.TranslationChapter.TranslationChunks
|
||||||
include: [
|
|
||||||
{
|
|
||||||
association: db.ArtifactVersion.Chapters,
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
association: db.Chapter.Chunks
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -353,12 +332,12 @@ module.exports = function (options) {
|
|||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}).then(backTranslation => {
|
}).then(translationArtifactVersion => {
|
||||||
if (backTranslation) {
|
if (translationArtifactVersion) {
|
||||||
response.redirect(`/library/${backTranslation.artifactId}`)
|
response.redirect(`/translate/${translationArtifactVersion.id}`)
|
||||||
} else {
|
} else {
|
||||||
// TODO: Let user know we cannot back translate
|
// TODO: Let user know we cannot back translate
|
||||||
response.redirect(`/translate/${request.params.id}`)
|
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
next(error)
|
next(error)
|
||||||
|
|||||||
@@ -12,7 +12,12 @@ block content
|
|||||||
table
|
table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th #{translationChapter.translationArtifactVersion.artifactVersion.artifact.dialect.name}
|
th
|
||||||
|
if translationChapter.translationArtifactVersion.backTranslationFrom
|
||||||
|
span= translationChapter.translationArtifactVersion.dialect.name
|
||||||
|
else
|
||||||
|
span #{translationChapter.translationArtifactVersion.artifactVersion.artifact.dialect.name}
|
||||||
|
|
||||||
th #{translationChapter.translationArtifactVersion.name}
|
th #{translationChapter.translationArtifactVersion.name}
|
||||||
th
|
th
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user