Skip to content

Commit

Permalink
FIX: Add quotes to translations (#69)
Browse files Browse the repository at this point in the history
closes #69
  • Loading branch information
dwhieb committed May 22, 2024
1 parent f03bb4b commit ca476fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/utterance/literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export default function createLiteral(data, { analysisLang }) {

if (typeof data === `string`) {
const lang = analysisLang ? `lang='${ analysisLang }'` : ``
return `<p class=lit><i lang=en>lit.</i> <span class=tln ${ lang }>${ addEmphasis(data) }</span></p>`
return `<p class=lit><i lang=en>lit.</i> <span class=tln ${ lang }>${ addEmphasis(data) }</span></p>`
}

let html = ``

for (const lang in data) {
const lit = data[lang]
html += `<p class=lit><i lang=en>lit.</i> <span class=tln lang='${ lang }'>${ addEmphasis(lit) }</span></p>`
html += `<p class=lit><i lang=en>lit.</i> <span class=tln lang='${ lang }'>${ addEmphasis(lit) }</span></p>`
}

return html
Expand Down
4 changes: 2 additions & 2 deletions src/utterance/translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export default function createTranslation(data, { analysisLang }) {

if (typeof data === `string`) {
const lang = analysisLang ? `lang='${ analysisLang }'` : ``
return `<p class=tln ${ lang }>${ addEmphasis(data) }</p>`
return `<p class=tln ${ lang }>${ addEmphasis(data) }</p>`
}

let html = ``

for (const lang in data) {
const tln = data[lang]
html += `<p class=tln lang='${ lang }'>${ addEmphasis(tln) }</p>`
html += `<p class=tln lang='${ lang }'>${ addEmphasis(tln) }</p>`
}

return html
Expand Down
16 changes: 13 additions & 3 deletions test/utterance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ describe(`utterance`, function() {
expect(getAttribute(lat, `lang`)).to.equal(`lat`)
expect(getAttribute(eng, `lang`)).to.equal(`eng`)
expect(getTextContent(lat)).to.include(`mittit`)
expect(getTextContent(eng)).to.include(`sends`)

const engText = getTextContent(eng)

expect(engText.startsWith(`‘`)).to.be.true
expect(engText).to.include(`sends`)
expect(engText.endsWith(`’`)).to.be.true

})

Expand Down Expand Up @@ -104,8 +109,13 @@ describe(`utterance`, function() {

expect(getAttribute(engLiteral, `lang`)).to.equal(`en`)
expect(getAttribute(spaLiteral, `lang`)).to.equal(`sp`)
expect(getTextContent(engLiteral)).to.equal(`they ate each other's mouths`)
expect(getTextContent(spaLiteral)).to.equal(`se comen sus bocas`)
expect(getTextContent(spaLiteral)).to.include(`se comen sus bocas`)

const engText = getTextContent(engLiteral)

expect(engText.startsWith(`‘`)).to.be.true
expect(engText).to.include(`they ate each other's mouths`)
expect(engText.endsWith(`’`)).to.be.true

})

Expand Down

0 comments on commit ca476fd

Please sign in to comment.