Welcome / Bienvenue / Benvinguts / Bienvenidos
For information about my translation services, please visit the main site.
Pour des informations sur mes services, merci de regarder le site principal.
Para información sobre mis servicios de traducción, visite el web principal.

Macro to prepare documents for monolingual review in memoQ (and possibly other CAT tools)

MemoQ’s monolingual review feature works best with clean Word documents containing no tracked changes or comments. If you import a document in which changes are still visible or in which there are comments, memoQ will add lots of code to the target text, which you don’t want.

This macro cleans the document up and saves it under a new filename (so that you don’t overwrite the commented version), making it ready to be imported as a monolingual review.

The macro includes comments to explain what some of the lines are doing and how you can adjust the macro to meet your needs.

Since many translators use only straight apostrophes and quotation marks in memoQ, then convert them to the curly variety in the final document sent to the client, the macro includes an optional line (deactivated by default) that will revert all apostrophes and quotation marks to the straight variety. Please read the instructions carefully if you wish to use that line.

Thanks to Kevin Mote, who provided the code for the part of the macro that renames the file. My code is a slightly modified version of his. In particular, unlike Kevin’s version, mine does not overwrite the old version, since most translators would want to keep a copy of the commented version they sent to their client.


Sub PrepareForMemoQMonolingualReview()
' memoQ's monolingual review feature works best when you import a document with no tracked changes and no comments.
' This macro removes them, then resaves the file with "clean-for-import" appended to the file name.
' The part that appends the filename is adapted from the macro provided by Kevin Mote (https://www.linkedin.com/in/kevinmote/) at https://superuser.com/a/781501. Thank you Kevin. This was very helpful!
' Please note that, unlike Kevin's macro, this version does not delete the original file.
Dim strFileFullName, strFileName, strNewName, strFileExtension As String
'
ActiveDocument.AcceptAllRevisions ' Accepts all tracked changes
ActiveDocument.TrackRevisions = False ' Switches off track changes
ActiveDocument.DeleteAllComments ' Deletes all comments in the active document.

ReplaceQuotes ' Reverts quotation marks and apostrophes back to the straight variety, assuming that this is the variety that was used while working in the CAT tool.
' Remove the apostrophe from the above line if you want the monolingual review document to revert to straight apostrophes and quotation marks.
' Note that to run the above line you also need to have installed the "ReplaceQuotes" and "QuotesReplacementBothWays" macros, which I provided along with several others in a blog post at http://www.anglopremier.com/blog/?p=1119.
' *****ADDITIONAL OPTION DESCRIBED ABOVE*****

' Get current name:
strFileFullName = ActiveDocument.FullName 'for Word docs
'strFileFullName = ActiveWorkbook.FullName 'Use this line instead for for Excel docs
'strFileFullName = Application.ActivePresentation.FullName 'Use this line instead for Powerpoint presentations
If (InStr(strFileFullName, ".") = 0) Then ' Checks whether the full file name contains a file extension by looking for a dot.
res = MsgBox("File has not been saved. Can't rename it.", , "Rename File")
Exit Sub
End If
' strFileName = Right(strFileFullName, Len(strFileFullName) - InStrRev(strFileFullName, "\")) 'strip path - not used. Next line used instead.
strFileName = strFileFullName
strFileExtension = Right(strFileName, Len(strFileName) - InStrRev(strFileName, ".")) ' Identifies the file extension
strFileName = Left(strFileName, (InStr(strFileName, ".") - 1)) ' Strips the extension from the strFileName variable
' If InStr(3, strFileName, "_Delivery", 1) <> 0 Then strFileName = Left(strFileName, (InStr(strFileName, "_Delivery", 1) - 1))
' The above line is not used. Originally intended to strip the word "_Delivery" and the delivery number from the file name (assumes "Delivery" is at least the third character; not case-sensitive). But I dedcided I wanted to keep the delivery number.
' If you wish to remove something from the file name you can reinstate the above line (remove the apostrophe) and replace "_Delivery" with whatever you want to remove.

' Prompt for new name. Replace "_clean-for-import" on the next line if you prefer something else to be appended by default.
strNewName = InputBox("Rename this file to:", "Rename File", strFileName & "_clean-for-import." & strFileExtension) 'Saves with the new name. Extension is not changed.
If (strNewName = "") Or (strNewName = strFileName) Then ' (Check whether user cancelled)
Exit Sub
End If

' Save file with new name:
ActiveDocument.SaveAs2 FileName:=strNewName 'for Word docs
'ActiveWorkbook.SaveAs2 FileName:=strNewName 'for Excel docs
'Application.ActivePresentation.SaveAs FileName:=strNewName 'for Powerpoint presentations

End Sub

Share:

AutoHotkey script to move the focus away from the Concordance window

Sometimes you want to keep the MemoQ Concordance window open on your second screen while you work on your document. But there’s no built-in method to achieve this with the keyboard. You can only do so by clicking with the mouse.

This short script moves the focus away from the Concordance window and to the main MemoQ window, allowing you to work on the document while keeping the Concordance window open. Just press ctrl+k to activate the script.


#IfWinActive, Concordance
^k:: ; MemoQ: Move focus away from Concordance window
WinActivate memoQ
#IfWinActive
return

The following script closes the Concordance window. Continue reading

Share:

Macro to replace smart quotes and smart apostrophes with straight quotes and straight apostrophes in Word

UPDATE: I no longer recommend this macro because it does not look at footnotes and text boxes. Instead, you should use the macro available here.

Many users of CAT tools like to convert smart quotes and apostrophes to straight ones before translating their documents, because if the straight versions are always used, it means concordance searches for words including apostrophes will always work.

The problem is that it takes quite a while to do this in MS Word. You can’t just find/replace the apostrophes, because even if you put a straight apostrophe in the replace box, Word will interpret it as a smart apostrophe if you have set Word up to use straight apostrophes and quotes.

Of course, you could change that setting, but then it is more complicated to convert the straight varieties to the smart varieties after exporting from your CAT tool.

The solution is to use a macro that will automatically switch smart quotes and apostrophes off, then perform the search, then switch them back on.

Here’s a macro that will do just that.

Option Explicit
Sub ReplaceQuotes()
' ReplaceQuotes Macro, by Timothy Barton, Anglo Premier Translations
'
Application.Options.AutoFormatAsYouTypeReplaceQuotes = False
Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting

With Selection.find
.Text = ChrW(8220)
.Replacement.Text = """"

.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.find.Execute Replace:=wdReplaceAll

Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting
With Selection.find
.Text = ChrW(8221)
.Replacement.Text = """"

End With
Selection.find.Execute Replace:=wdReplaceAll

Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting
With Selection.find
.Text = "´"
.Replacement.Text = "'"

.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.find.Execute Replace:=wdReplaceAll

Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting
With Selection.find
.Text = "‘"
.Replacement.Text = "'"

.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.find.Execute Replace:=wdReplaceAll

Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting
With Selection.find
.Text = "’"
.Replacement.Text = "'"

.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.find.Execute Replace:=wdReplaceAll
Application.Options.AutoFormatAsYouTypeReplaceQuotes = True

Dim oShell As Object
Dim iResponse As Integer
Set oShell = CreateObject("Wscript.Shell")

iResponse = MsgBox("Procedure complete. Code provided by Timothy Barton, Anglo Premier Translations. Would you like to visit the website?", _
vbYesNo, "Procedure complete")

If iResponse = vbYes Then
oShell.Run ("http://www.anglopremier.com?utm_campaign=apostrophesmacro&utm_medium=referral&utm_source=blog")
Else
Exit Sub
End If

End Sub

Share:

AHK scripts to change status in MemoQ

These Autohotkey scripts allow MemoQ users to switch between the Confirmed, Reviewed and Proofread user statuses using the keyboard. The shortcuts are shift-ctrl-z, shift-ctrl-x and shift-ctrl-c. Users of keyboards that don’t have the z, x and c next to each other may wish to change the shortcuts in the code.

; Set "Confirmed"
SetTitleMatchMode, 2
#IfWinActive, memoQ
+^z::
setkeydelay, 20
send, !v{down 6}

sleep 100
send {Enter}
sleep 100
send, +{TAB 6}
send, c

;return to document
send +^{tab}
sleep 100
return

; Set "Reviewer"
SetTitleMatchMode, 2
#IfWinActive, memoQ
+^x::

;from Translations pane
setkeydelay, 10
send, !v{down 6}

sleep 100
send {Enter}
sleep 100
send, +{TAB 6}
send, r

;return to document
send +^{tab}
sleep 100
return

; Set "Proofreader"
SetTitleMatchMode, 2
#IfWinActive, memoQ
+^c::

;from Translations pane
setkeydelay, 10
send, !v{down 6}

sleep 100
send {Enter}
sleep 100
send, +{TAB 6}
send, p

;return to document
send +^{tab}
sleep 100
return

Share:

Translating Latex files in MemoQ

LaTeX is a format that uses tags to enable authors to not have to worry about typesetting their text. Unfortunately, at the time of writing there do not seem to be any CAT tools that accept this format. However, MemoQ lets you label tags using regular expressions. We have created a filter for importing LaTeX files into MemoQ. If you normally use a different CAT tool, you could import your file into MemoQ (you can use the demo version for up to 45 days) then export it into a format you can use in other CAT tools (for example, the XLIFF format).

To use the filter, download it here. Next, go to the Resource console in MemoQ and click on “Filter configurations”. Click “Import new” and add the file you just downloaded.

Now all you need to do is go to “Add document as” in a MemoQ project, click on the “Open” button in the Document import settings window and select “Latex all” from the list.

Share: