Format chemical formulas for translating
Autor wątku: Hans Lenting
Hans Lenting
Hans Lenting
Holandia
Członek ProZ.com
od 2006

niemiecki > niderlandzki
Oct 19, 2021

Subscript numbers in chemical formulas cause a lot of unnecessary tags in CAT tools and they often prevent term recognition and auto-translation. So why not convert them to Unicode?

Sub ConvertSubscriptNumberToEquivalentUnicodeCharacter()
Dim strAscii

Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = False
.Subscript = True
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = False
.Subscript = False
End With
For strAscii = 1 To 9
With Selection.Find
.Text = strAscii
.Replacement.Text = ChrW(strAscii + 8320)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next strAscii
End Sub


1

Instead of:

Screen Shot 2021-10-19 at 19.39.28

You'll get:

Screen Shot 2021-10-19 at 19.39.37

Clearer view and term recognition.

On a side note: Same goes for Ms Word's bullets, arrows, Wingdings etc.: it would be nice to have them converted to Unicode.

Stanislav, are you reading this?

https://www.alt-codes.net/arrow_alt_codes.php

https://www.alt-codes.net/bullet_alt_codes.php

Same goes for frequently used superscripts like TM etc., which can be replaced by their Unicode equivalents.

I found that (C), (R) can be replaced by © and ®, but you'll have to maintain the superscript formatting, since these characters aren't superscript themselves ...

So that macro would be something like:

Sub ConvertSuperscriptsToUnicode()

Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = True
.Subscript = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = False
.Subscript = False
End With

With Selection.Find
.Text = "TM"
.Replacement.Text = "™"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
.Subscript = False
End With
With Selection.Find
.Text = "(C)"
.Replacement.Text = "©"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
.Subscript = False
End With
With Selection.Find
.Text = "(R)"
.Replacement.Text = "®"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

End Sub



[Edited at 2021-10-20 05:50 GMT]


 
Stanislav Okhvat
Stanislav Okhvat
Local time: 07:12
angielski > rosyjski
Replacing characters with their Unicode equivalents Oct 20, 2021

Hello Hans,

Thank you for the useful macro!

There are 2 tools in TransTools and TransTools+ that do similar things, although they do not cover subscripted digits:

1) In Document Cleaner > Tag Cleaner (TransTools for Word) (www.translatortools.net/products/transtools/doccleaner), there is an option called "Replace special symbols with regular characters where appropri
... See more
Hello Hans,

Thank you for the useful macro!

There are 2 tools in TransTools and TransTools+ that do similar things, although they do not cover subscripted digits:

1) In Document Cleaner > Tag Cleaner (TransTools for Word) (www.translatortools.net/products/transtools/doccleaner), there is an option called "Replace special symbols with regular characters where appropriate". This converts several symbols from the Symbol font commonly used in Word to their Unicode equivalents to help reduce redundant tags. This option is not enabled by default.

2) In Spacing, Punctuation and Symbol Correction Tool (TransTools+, Word) (www.translatortools.net/products/transtoolsplus/word-symbolizer), there are several options to convert text like (TM), (C), (R), superscript 0 or o used as a degree sign, etc. to Unicode symbols. At the same time, this tool does not perform conversion of characters written in Symbol font, nor does it work on subscripted digits like your macro does.

I will put it into my to-do list to add conversion of subscripted digits to this tool. Thank you for this idea.

Best regards,
Stanislav Okhvat
TransTools – Useful tools for every translator
Collapse


 
Hans Lenting
Hans Lenting
Holandia
Członek ProZ.com
od 2006

niemiecki > niderlandzki
NOWY TEMAT
Enclosed numbers Oct 26, 2021

Enclosed numbers 1 to 20:

Sub ConvertEnclosedNumbersToEquivalentUnicodeCharacters()
Dim strAscii

Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = False
.Subscript = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = False
.Subscript = False
End With
For strAscii = 1 To 20
With Selection.Find
.Text = "(" & strAscii & ")"
.Replacement.Text = ChrW(strAscii + 9311)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next strAscii
End Sub


https://www.dropbox.com/s/ej6dbuc4cip8t4l/enclosed_numbers.gif?dl=1

On a side note: Looks like it's no longer possible to upload GIF files. What would be the appropriate file format for animations?



[Edited at 2021-10-26 14:54 GMT]


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Format chemical formulas for translating






Trados Studio 2022 Freelance
The leading translation software used by over 270,000 translators.

Designed with your feedback in mind, Trados Studio 2022 delivers an unrivalled, powerful desktop and cloud solution, empowering you to work in the most efficient and cost-effective way.

More info »
Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »