Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions src/components/panels/edit/fields/Literal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,85 @@ export default {
let highlightTemplate = null
if (textarea && textarea.selectionStart !== textarea.selectionEnd) {
let highlightedText = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd)


// if there is multiple values in the literalValues and they have @language meaning they are transliterated already
if (this.literalValues.length > 1){
let hasLatin = false
let hasNonLatin = false

for (let lv of this.literalValues){
if (lv['@language'] && lv['@language'].toLowerCase().includes('latn')){
hasLatin=true
}else if (lv['@language'] && !lv['@language'].toLowerCase().includes('latn')){
hasNonLatin=true
}
}
if (hasLatin && hasNonLatin){

// get the script information from the other field that is not this one
let otherFieldValue = this.literalValues.filter((v)=>{ return (v['@guid'] != options.fieldGuid) })

if (otherFieldValue){

// get the transliterated value from the highlited text

// let transValue = await utilsNetwork.scriptShifterRequestTrans(options.lang,highlightedText,null,options.dir)

// console

// loop through all of this.scriptShifterLangCodes and see if we can find the code == the other field
let otherScriptCodes = []
for (let key in this.scriptShifterLangCodes){
let codeObj = this.scriptShifterLangCodes[key]
// console.log("codeObj", codeObj)
// console.log("otherFieldValue[0]['@language']", otherFieldValue[0]['@language'])
if (fieldValue[0]['@language'] && codeObj.code.toLowerCase() == fieldValue[0]['@language'].toLowerCase()){
otherScriptCodes.push(key)

}else{
console.log(codeObj.code.toLowerCase(), "!= ", otherFieldValue[0]['@language'].toLowerCase())
}
}


// remove the current req from the otherScriptCodes
otherScriptCodes = otherScriptCodes.filter((code)=>{ return code != options.lang })
let didReplaceTransliteration = false
// send a utilsNetwork.scriptShifterRequestTrans for each otherScriptCodes
for (let osc of otherScriptCodes){
let transValue = await utilsNetwork.scriptShifterRequestTrans(osc,highlightedText,null,options.dir)
// now replace the highlighted text in the otherField
console.log("transliterated text highlightedText:", osc, transValue)
// see if we can find transValue text in the other field value
if (otherFieldValue[0].value.indexOf(transValue.output) > -1){

// okay we found it then do the transliteration for this value highleted text and get the results
let thisTransValue = await utilsNetwork.scriptShifterRequestTrans(options.lang,highlightedText,null,options.dir)

// and replce the transValue.output text in the other field with thisTransValue.output using this.profileStore.setValueLiteral
let newOtherValue = otherFieldValue[0].value.replace(transValue.output, thisTransValue.output)
this.profileStore.setValueLiteral(this.guid,otherFieldValue[0]['@guid'],this.propertyPath,newOtherValue,otherFieldValue[0]['@language'] )

didReplaceTransliteration = true
break

}
}
if (didReplaceTransliteration){
return false
}



}else{
alert("Error: Could not find the other field value for this literal, cannot do transliteration overwrite.")
}
// and they are currently in the

}
}

useTextToTrans = highlightedText
highlightTemplate = fieldValue[0].value.replace(highlightedText, '<TRANSLITERATED_TEXT_HERE>')
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/panels/edit/modals/NacoStubCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,8 @@

if (this.statementOfResponsibility && this.statementOfResponsibility.split(/,?\s+and\s+|,/).length>1){
this.statementOfResponsibilityOptions = this.statementOfResponsibility.split(/,?\s+and\s+|,/)
} else if (this.statementOfResponsibility && this.statementOfResponsibility.split(/,?\s+und\s+|\s+e\s+|;/).length>1){
this.statementOfResponsibilityOptions = this.statementOfResponsibility.split(/,?\s+und\s+|\s+e\s+|;/)
}

let addingDefaultExtraMarcStatements = false
Expand Down