@@ -121,21 +121,24 @@ Sub shouldAddSpace(sourceLang As String,targetLang As String,index As Int,segmen
121
121
Return False
122
122
End Sub
123
123
124
- Sub exportToMarkdownWithNotes (segments As List ,path As String ,filename As String ,sourceLang As String ,targetLang As String ,settings As Map )
124
+ Sub exportToMarkdownWithNotes (segments As List ,path As String ,filename As String ,sourceLang As String ,targetLang As String ,settings As Map ,projectPath As String )
125
125
Dim text As StringBuilder
126
126
text.Initialize
127
127
Dim noteIndex As Int =0
128
128
Dim noteText As StringBuilder
129
129
noteText.Initialize
130
130
noteText.Append(CRLF).Append(CRLF)
131
131
Dim previousID As String ="-1"
132
+ Dim previousInnerFilename As String =""
132
133
Dim index As Int =-1
133
134
For Each segment As List In segments
134
135
index=index+1
135
136
Dim source,target,fullsource As String
136
137
Dim translation As String
138
+ Dim innerFilename As String
137
139
source=segment.Get (0 )
138
140
target=segment.Get (1 )
141
+ innerFilename=segment.Get (3 )
139
142
If target="" Then
140
143
target=source
141
144
Else
@@ -162,12 +165,18 @@ Sub exportToMarkdownWithNotes(segments As List,path As String,filename As String
162
165
previousID=id
163
166
End If
164
167
End If
168
+ If innerFilename<>previousInnerFilename Then
169
+ fullsource=CRLF&fullsource
170
+ previousInnerFilename=innerFilename
171
+ End If
165
172
source=Regex.Replace2("<.*?>" ,32 ,source,"" )
166
173
target=Regex.Replace2("<.*?>" ,32 ,target,"" )
167
174
fullsource=Regex.Replace2("<.*?>" ,32 ,fullsource,"" )
168
175
translation=fullsource.Replace(source,target)
169
176
If LanguageHasSpace(targetLang)=False Then
170
- translation=segmentation.removeSpacesAtBothSides(path,targetLang,translation,settings.GetDefault("remove_space" ,True ))
177
+ If source<>target Then
178
+ translation=segmentation.removeSpacesAtBothSides(projectPath,targetLang,translation,settings.GetDefault("remove_space" ,True ))
179
+ End If
171
180
End If
172
181
text.Append(translation)
173
182
Next
@@ -177,19 +186,24 @@ Sub exportToMarkdownWithNotes(segments As List,path As String,filename As String
177
186
File.WriteString(path,"" ,result)
178
187
End Sub
179
188
180
- Sub exportToBiParagraph (segments As List ,path As String ,filename As String ,sourceLang As String ,targetLang As String ,settings As Map )
189
+ Sub exportToBiParagraph (segments As List ,path As String ,filename As String ,sourceLang As String ,targetLang As String ,settings As Map ,projectPath As String )
181
190
Dim text As StringBuilder
182
191
text.Initialize
183
- Dim sourceText As String
184
- Dim targetText As String
192
+ Dim sourceText As StringBuilder
193
+ sourceText.Initialize
194
+ Dim targetText As StringBuilder
195
+ targetText.Initialize
185
196
Dim previousID As String ="-1"
197
+ Dim previousInnerFilename As String =""
186
198
Dim index As Int =-1
187
199
For Each segment As List In segments
188
200
index=index+1
189
201
Dim source,target,fullsource As String
190
202
Dim translation As String
203
+ Dim innerFilename As String
191
204
source=segment.Get (0 )
192
205
target=segment.Get (1 )
206
+ innerFilename=segment.Get (3 )
193
207
If shouldAddSpace(sourceLang,targetLang,index,segments) Then
194
208
target=target&" "
195
209
End If
@@ -204,21 +218,27 @@ Sub exportToBiParagraph(segments As List,path As String,filename As String,sourc
204
218
previousID=id
205
219
End If
206
220
End If
221
+ If innerFilename<>previousInnerFilename Then
222
+ fullsource=CRLF&fullsource
223
+ previousInnerFilename=innerFilename
224
+ End If
207
225
source=Regex.Replace2("<.*?>" ,32 ,source,"" )
208
226
target=Regex.Replace2("<.*?>" ,32 ,target,"" )
209
227
fullsource=Regex.Replace2("<.*?>" ,32 ,fullsource,"" )
210
228
translation=fullsource.Replace(source,target)
211
229
If LanguageHasSpace(targetLang)=False Then
212
- translation=segmentation.removeSpacesAtBothSides(path,targetLang,translation,settings.GetDefault("remove_space" ,True ))
230
+ If source<>target Then
231
+ translation=segmentation.removeSpacesAtBothSides(projectPath,targetLang,translation,settings.GetDefault("remove_space" ,True ))
232
+ End If
213
233
End If
214
- sourceText=sourceText& fullsource
215
- targetText=targetText& translation
234
+ sourceText.Append( fullsource)
235
+ targetText.Append( translation)
216
236
Next
217
237
Dim sourceList,targetList As List
218
238
sourceList.Initialize
219
239
targetList.Initialize
220
- sourceList.AddAll(Regex.Split(CRLF,sourceText))
221
- targetList.AddAll(Regex.Split(CRLF,targetText))
240
+ sourceList.AddAll(Regex.Split(CRLF,sourceText.ToString ))
241
+ targetList.AddAll(Regex.Split(CRLF,targetText.ToString ))
222
242
For i=0 To Min(sourceList.Size,targetList.Size)-1
223
243
text.Append(sourceList.Get (i)).Append(CRLF)
224
244
text.Append(targetList.Get (i)).Append(CRLF).Append(CRLF)
0 commit comments