Skip to content

Commit

Permalink
replace <target /> to <target></target> for xliff filter
Browse files Browse the repository at this point in the history
  • Loading branch information
xulihang committed Apr 28, 2020
1 parent fa15eaf commit e180da0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
30 changes: 15 additions & 15 deletions BasicCAT/BasicCAT.b4j
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,22 @@ Library9=jb4xencryption
Module1=FileChooserUtils
Module10=preTranslateDialog
Module11=xliffFilter
Module12=SRX
Module13=TMX
Module14=LanguageTool
Module15=TMDB
Module16=LanguageUtils
Module17=importDialog
Module18=progressDialog
Module19=TMManager
Module12=XMLUtils
Module13=SRX
Module14=TMX
Module15=LanguageTool
Module16=TMDB
Module17=LanguageUtils
Module18=importDialog
Module19=progressDialog
Module2=Project
Module20=TermManager
Module21=statistics
Module22=ClientKVS
Module23=Utils
Module24=MT
Module25=idmlFilter
Module26=XMLUtils
Module20=TMManager
Module21=TermManager
Module22=statistics
Module23=ClientKVS
Module24=Utils
Module25=MT
Module26=idmlFilter
Module27=SearchView
Module28=idmlUtils
Module29=Preferences
Expand Down
4 changes: 2 additions & 2 deletions BasicCAT/BasicCAT.b4j.meta
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,6 @@ ModuleClosedNodes68=
ModuleClosedNodes7=
ModuleClosedNodes8=
ModuleClosedNodes9=
NavigationStack=TMX,Process_Globals,9,0,TMX,export,223,0,segmentation,segmentedTxtSimpleway,227,0,txtFilter,createWorkFile,5,0,segmentation,segmentedTxt,36,0,xliffFilter,addFromGroups,185,0,xliffFilter,getTransUnits,155,0,XMLUtils,escapedText,54,0,xliffFilter,createWorkFile,17,6,xliffFilter,addTransUnit,226,6
NavigationStack=xliffFilter,Process_Globals,5,0,xliffFilter,updateTransUnits,493,0,xliffFilter,shouldAddSpace,571,0,xliffFilter,mergeSegment,605,0,XMLUtils,GetElements,38,0,XMLUtils,escapedText,55,6,xliffFilter,createWorkFile,19,6,xliffFilter,checkSegContinuous,354,0,xliffFilter,insertTranslation,355,0,xliffFilter,generateFile,339,0
SelectedBuild=0
VisibleModules=1,2,3,4,5,6,7,8,9,10,11,26
VisibleModules=1,2,3,4,5,6,7,8,9,10,11,12
2 changes: 1 addition & 1 deletion BasicCAT/Files/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.1
1.7.2
17 changes: 10 additions & 7 deletions BasicCAT/xliffFilter.bas
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ Sub createWorkFile(filename As String,path As String,sourceLang As String,senten
Dim files As List
Dim xmlstring As String=File.ReadString(File.Combine(path,"source"),filename)
xmlstring=XMLUtils.escapedText(xmlstring,"source","xliff")
xmlstring=XMLUtils.escapedText(xmlstring,"target","xliff")
xmlstring=XMLUtils.escapedText(xmlstring,"mrk","xliff")
'Log("done")
xmlstring=Regex.Replace("<target\b.*?/>",xmlstring,"<target></target>")
xmlstring=XMLUtils.escapedText(xmlstring,"target","xliff")
Log("escape done")


files=getFilesList(xmlstring)
Expand Down Expand Up @@ -341,8 +342,9 @@ Sub generateFile(filename As String,path As String,projectFile As Map)
Dim xmlString As String
xmlString=XMLUtils.getXmlFromMapWithoutIndent(insertTranslation(translationMap,filename,path,isSegEnabled))
xmlString=XMLUtils.unescapedText(xmlString,"source","xliff")
xmlString=XMLUtils.unescapedText(xmlString,"target","xliff")
xmlString=XMLUtils.unescapedText(xmlString,"seg-source","xliff")
'xmlString=Regex.Replace("<target\b.*?/>",xmlString,"<target></target>")
xmlString=XMLUtils.unescapedText(xmlString,"target","xliff")
'Log(xmlString)
File.WriteString(File.Combine(path,"target"),filename,xmlString)
Main.updateOperation(filename&" generated!")
Expand All @@ -363,6 +365,7 @@ Sub insertTranslation(translationMap As Map,filename As String,path As String,is
xmlstring=XMLUtils.escapedText(xmlstring,"source","xliff")
xmlstring=XMLUtils.escapedText(xmlstring,"seg-source","xliff")
If isSegEnabled=False Then
xmlstring=Regex.Replace("<target\b.*?/>",xmlstring,"<target></target>")
xmlstring=XMLUtils.escapedText(xmlstring,"target","xliff")
End If
'File.WriteString(path,"out.xml",xmlstring)
Expand All @@ -383,7 +386,7 @@ Sub insertTranslation(translationMap As Map,filename As String,path As String,is
Try
body=innerFile.Get("body")
Catch
Log(LastException)
'Log(LastException)
Continue
End Try
Dim fileAttributes As Map
Expand Down Expand Up @@ -497,14 +500,14 @@ Sub updateTransUnits(transUnits As List,originalFilename As String,translationMa
End If
Else
For Each key As String In targetMap.Keys
Log(key)
Log(targetMap)
'Log(key)
'Log(targetMap)
Try
If key<>"Attributes" Then
targetMap.Remove(key)
End If
Catch
Log(LastException)
'Log(LastException)
End Try
Next
targetMap.Put("Text",dataMap.Get("translation"))
Expand Down

0 comments on commit e180da0

Please sign in to comment.