Forum: CAT Tools Technical Help
Topic: Simple markups for bold and italics in TMX?
Poster: Hans Lenting
Post title: Good suggestion!
[quote]Samuel Murray wrote:
So, just to be clear, if your TMX file contains this:
The «bpt»B«/bpt»cat«ept»b«/ept» sat on the «bpt»B«/bpt»mat«ept»b«/ept».
...and you are translating e.g. an HTML file with the text "The «b»cat«/b» sat on the «b»mat«/b»." and your CAT tool correctly identifies the «b» and «/b» as tags in the HTML file, then it will be a 100% match for the TU shown above, despite the fact that the TU uses "B" and "b" for the tags and not «b» and «/b».[/quote]
I came up with this solution, for bold, italics, underlined, superscript and subscript:
Different CAT tools may have different requirements for the properties in the header, but I had to add «prop type="x-processing_tags"»true«/prop» in order to make full matches possible.
In VBA the marking up would look like:
Sub ReplaceCharacterFormattingWithMarkup()
'Replace character formatting with markup in TMX style
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»B«/bpt»^&«ept»b«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Italic = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»I«/bpt»^&«ept»i«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.Bold = False
.Italic = False
.Superscript = True
.Subscript = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Superscript = False
.Subscript = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»P«/bpt»^&«ept»p«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = False
.Subscript = True
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Superscript = False
.Subscript = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»S«/bpt»^&«ept»s«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Underline = wdUnderlineSingle
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Underline = False
.Superscript = False
.Subscript = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»U«/bpt»^&«ept»u«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
[Edited at 2022-09-10 10:59 GMT]
Topic: Simple markups for bold and italics in TMX?
Poster: Hans Lenting
Post title: Good suggestion!
[quote]Samuel Murray wrote:
So, just to be clear, if your TMX file contains this:
The «bpt»B«/bpt»cat«ept»b«/ept» sat on the «bpt»B«/bpt»mat«ept»b«/ept».
...and you are translating e.g. an HTML file with the text "The «b»cat«/b» sat on the «b»mat«/b»." and your CAT tool correctly identifies the «b» and «/b» as tags in the HTML file, then it will be a 100% match for the TU shown above, despite the fact that the TU uses "B" and "b" for the tags and not «b» and «/b».[/quote]
I came up with this solution, for bold, italics, underlined, superscript and subscript:
Different CAT tools may have different requirements for the properties in the header, but I had to add «prop type="x-processing_tags"»true«/prop» in order to make full matches possible.
In VBA the marking up would look like:
Sub ReplaceCharacterFormattingWithMarkup()
'Replace character formatting with markup in TMX style
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»B«/bpt»^&«ept»b«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Italic = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»I«/bpt»^&«ept»i«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.Bold = False
.Italic = False
.Superscript = True
.Subscript = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Superscript = False
.Subscript = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»P«/bpt»^&«ept»p«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = False
.Subscript = True
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Superscript = False
.Subscript = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»S«/bpt»^&«ept»s«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Underline = wdUnderlineSingle
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Underline = False
.Superscript = False
.Subscript = False
End With
With Selection.Find
.Text = ""
.Replacement.Text = "«bpt»U«/bpt»^&«ept»u«/ept»"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
[Edited at 2022-09-10 10:59 GMT]