Showing posts with label MemoQ. Show all posts
Showing posts with label MemoQ. Show all posts

Friday, September 8, 2023

MemoQ Unsigned OPUSCAT Plug-in Warning

 To get rid of the memoQ unsigned plug-in warning that OpusCAT triggers, you need to create a ClientDevConfig.xml file under ProgramData/MemoQ containing just the following code:

 <?xml version="1.0" encoding="utf-8"?>
<ClientDevConfig>
<LoadUnsignedPlugins>true</LoadUnsignedPlugins>
</ClientDevConfig>

Source: https://github.com/Helsinki-NLP/OPUS-CAT

Try:

Installation:

  1. Download and unpack the zip file.
  2. Copy the ClientDevConfig.xml file to your %programdata%/MemoQ folder. This is usually located at C:\Users\\$USERNAME\AppData\Roaming\MemoQ or C:\Users\\$USERNAME\AppData\Local\MemoQ, but note that the AppData folder is hidden, so you may need to enable "Show hidden items" in the Windows Explorer settings.
  3. Copy the .dll file to the Addins folder of your MemoQ installation (C:\Program Files\memoQ\memoQ-9\Addins). Make sure to delete any previous plugin files.

Troubleshooting:

  • If an error message regarding CAS policy is displayed upon MemoQ startup, unzip it using 3rd party software (such as WinRar). This is because Windows flags .dll files that have been downloaded on their own or inside a .zip file that is unpacked using Windows Explorer.
  • If you notice incompatibility issues or other errors, please open an issue under this repository.

Saturday, July 28, 2018

MemoQ MT tag editing

Support for Machine Translation (MT) is done în MemoQ through series of plugins. Pseudo-translation which is fine, but limited. Although they’ve enhanced it in Adriatic version. Second plugin is for Google Translate. There’s not much in terms of configuration, you set the API key, can specify regex which matches will be ignored in MT process, and enable option to put the tags from source at the end of the translation.
Word of advice here. If plugin is enabled and set as preferred in your client, MT results show up alongside Translation Memory ™ hits in Translation results pane. So if you spend a lot of time there clicking through segments it’ll cost you some money. Make sure to uncheck Offer machine-translated results while working in the translation grid or adjust it to your actual needs.
Tags in memoQ, as in other localization tools, serve as placeholders for source file elements which are wrapping or are placed between text to be translated. If you translate Word documents your tags will be mainly formatting. So, if these tags will be placed at the end of translation, formatting will be broken. Which is maybe not big thing if you’re using MT as support to human translation, because your translator will place tags where they belong. Although he probably won’t be very happy about it. But I’ve wanted to use MT as some kind of self-service for teams which don’t require quality translations, just want to understand the text.
Luckily memoQ offers export/import of bilingual files and its native format is mqxliff which is XML. Each segment is wrapped in trans-unit tag. Source segment if it contains tags looks like this.
<source xml:space="preserve" mq:segpart="8">You can <bpt id="1" ctype="underlined">{}</bpt>
<bpt id="2">&lt;hlnk id=&quot;rId8&quot; history=&quot;1&quot; fileName=&quot;document.xml&quot; href=&quot;@07c1b597-2ac9-446f-b816-78a8a151172a&quot;&gt;</bpt>
<bpt id="3">&lt;rpr id=&quot;0&quot;&gt;</bpt>download it here for free<ept id="1">{}</ept>
<ept id="3">&lt;/rpr id=&quot;0&quot; transform=&quot;close&quot;&gt;</ept><ept id="2">&lt;/hlnk&gt;</ept>.</source>
We need to work on XML level as we want these tags encoded back exactly as they’re now. First we need to get rid of source tags, I don’t like regex in my code, but this time it’s necessary </?source(.+?)?>. Now we have this.
You can <bpt id="1" ctype="underlined">{}</bpt>
<bpt id="2">&lt;hlnk id=&quot;rId8&quot; history=&quot;1&quot; fileName=&quot;document.xml&quot; href=&quot;@07c1b597-2ac9-446f-b816-78a8a151172a&quot;&gt;</bpt>
<bpt id="3">&lt;rpr id=&quot;0&quot;&gt;</bpt>download it here for free<ept id="1">{}</ept>
<ept id="3">&lt;/rpr id=&quot;0&quot; transform=&quot;close&quot;&gt;</ept><ept id="2">&lt;/hlnk&gt;</ept>.
Not bad, but still you don’t want to translate tags, so we’ll split this with another regex (<.+?>.+?</.+?>) to get nice array of strings. And then if item in array starts with < we add it as-is to target tag, else we first MT it.
Of course we could pass it as-is to Google Translate and receive back translation with tags intact, but then while adding it to original mqxliff all tags will be escaped, like &lt;bpt id="1" ctype="underlined"&gt;. And after import they’ll appear as regular text in memoQ and will be exported to DOCX (or whatever was original format) as such. So not only formatting will be broken, you’ll have garbage text within your translated text.
Last, but very important, thing. We need to set mq:status attribute for each changed trans-unit tag, so it equals "MachineTranslated". Otherwise even though we have translation for memoQ it’s empty and on export it’ll either not be exported or reverted to source text, depending on your settings.
As I was digging through mqxliff I’ve found another interesting thing. If segment is locked, it has following attributes translate="no" mq:locked="locked". Apparently, it’s enough to remove them from trans-unit tag and after import segment will be unlocked in memoQ project. It’s very useful as currently you need to have PM license to be able to lock/unlock segments, which is expensive. Plus, it’s tedious task if you need to do it manually. Source: https://blog.liox.eu

Memsource files in MemoQ

When it comes to online CAT-tools I personally consider Memsource as one of the better ones – it’s reasonably fast, offers decent functionality and usability. It’s even better with local (but not offline) client, which can undock some windows, so you can have concordance and TM matches on screen at the same time. Still, it’s not the same as memoQ when it comes to comfort and features, so whenever possible, I process Memsource files in memoQ – that is, if PM allows to download .mxliff files for work with local tool.

To do so I’m running pre-translation with relatively low threshold, download project files and open them in memoQ with another copy in Memsource for concordance and TB checks. After translation I open the files in memsource editor and use upload functionality to synchronize files with the server.
Unfortunately, the XLIFF format is a bit loose when it comes to how certain features should be implemented, so things like match rate and translation status are not imported by default and need some tinkering. I have created a template that can be used to import Memsource files in a bit more comfortable way.

There is a substantial edit concerning the template:

Originally .mxliff files were modified only before importing into memoQ, and I left cleaning up extra content to memsource editor. Now when you export finished translation, extra bits added for memoQ’s compatibility will be removed.
Additionally:
  1. Segments confirmed in memoQ will show as confirmed in Memsource. Of course you should still update the Memsource TM.
  2. Content of “Alt-trans” imported by default to memoQ from Memsource as comment will be ignored now. I was asked by multiple users to disable this. If you want alternative translations from Memsource, you can enable them in memoQ filter filter options.
  3. I removed my export path rules from template settings – this was causing problems for some users. Still, it’s a good idea to edit export path rules so memoQ will overwrite original files and you won’t have to manually re-name files exported from memoQ (to remove defalut “_iso” target language addition).
Original post content (still valid):
The template work by performing automated actions: the files are edited with regex-based Find and Replace rules to insert additional attributes for match rate and segment states (regex rules are included in .xml configuration files). Subsequently customixed XLIFF filter is used, configured to recognize the introduced attributes and regex-based tagging is run to convert Memsource tags into memoQ tags.
To use the template you need to follow instructions below for import and setup. When everything is configured correctly, you can create project from template and work with Memsource files more comfortably. But always remember to back up your files in case something goes wrong. Also while the conversions and template were tested by two people without any issues (at the time of publication), I can’t predict every possible case and setup, so you are doing this at your own risk – if something goes wrong, I may tray to help, but I won’t be held responsible.
Before you start: the template will work only with memoQ 8.x and 7.8, not older. However, executable file “FindAndReplace.exe” is only installed with memoQ version 8.1 and newer. If you have older version, you need to download it separately (see below).
Template Memsource does the following:
  • match rate will be visible in memoQ
  • locked status will be kept (segments locked in memsource will be locked in memoQ)
  • “translated” status will be kept
  • segments populated with machine translation will have “MT” status in memoQ
  • memsource tags will be converted into memoQ tags

Preparation:

1. memoQ version 8.1 and newer: none
2. memoQ version 7.8: download and unzip executable FindAndReplace (alternatively download and install newest memoQ version, you can still use 7.8, but FindAndReplace will be installed in the default path).

Installation:

  1. Download this file: memsource_updated.zip
  2. Unzip the content (remember where you unzipped it).
  3. Start memoQ, open Resource console.
  4. Select Filter configurations.
  5. Select Import new and import:  ChainedConverter#memsource-tagged.mqres
  6. Select Project templates.
  7. Select Import new > Memsource.mqres
    The template contains hard-coded path for configuration file: C:\memoQ\FindAndReplace\memsource.xml. If you don’t want to edit the template, create this folder and put “memsource.xml” in this path. Alternatively edit the template:
    Select Resource console > Templates > memsource with states > Edit > Automated actions > Script before import and edit path in Command line arguments field, then click Update.
    You can now create template project and import Memsource files.
Tagging mechanism will create empty (single) tags for numbers enclosed in curly brackets ( {1} ), opening (left) tags for any content starting with left curly bracket and closed by “greater than” sign (e.g. {1> or {i> ) and closing (right) tags for any content starting with “less than” sign closed by right curly bracket (e.g. <1} or <i} ). However, it is unlikely but possible that incorrect content will be tagged. In such case please contact me.
PRO tip: File extension “mxliff” is not recognized by memoQ, so when you are adding files to memoQ project, you need to “Show all“. But when you create a project based on this template you can skip “Add files” step (just don’t add any files) and when the template-based project is created, simply drag and drop mxliff files into “Translations” memoQ window. Files will be recognized and correct filter will be applied automatically.

To update already installed template you need to:

  1. Using resouce console delete existing filter configuration and project template and install updated version
    OR
  2. Using resouce console rename existing filter configuration and project template and install updated version
    OR
  3. Import updated filter configuration with new name, import updated project template with new name and modify it to include updated filter configuration name.
Please note: the templates reference FindAndReplace.exe file, which should be available at C:\Program Files (x86)\Kilgray\FindAndReplace Tool folder (for memoQ 8.1 and up). If you have non-standard memoQ installation path, you need to edit exe configuration in template settings (see below). If you have memoQ version older than 8.1, you need to download the file separately and edit the path in template settings:
  1. Select Resource console > Templates > memsource with states > Edit > Automated actions > Script before import > Select findandreplace.exe and click Delete.
  2. Click Add files…, browse to and select FindAndReplace.exe.
  3. Click Update.
Template can be further customized with your default languages, TMs, light resources etc.
Additional help for templates with find and replace scripts can be found here: https://help.memoq.com/8-3/en/index.html?edit-template-find-and-replace.html
Template configuration file (actual find and replace commands) is commented and you can customize it any way you like. Source: http://wasaty.pl

Thursday, December 7, 2017

MemoQ and VBS

A simple snippet of script code for exporting a TM to TMX has been circulating for a while now as a VBA macro to run from Microsoft Word, for example. Personally, I object to running something in MS Word that has nothing to do with that program, so I recoded it as an executable script and added a few extra tweaks:

tmFolder = InputBox("Which TM should be exported?")
if tmFolder <> "" then

' The path where all my memoQ TMs are stored
standardTMpath = "C:\ProgramData\MemoQ\Translation Memories\"

'build absolute paths
outputTMXfile =  ".\" & tmFolder & "_" & date() & ".tmx"
tmFolder = standardTMpath & tmFolder

Set fact = CreateObject("MemoQ.ClientService.ServiceFactoryScripting")
Set tmService = fact.CreateTMService
Set createTMRes = tmService.ExportToTMX(tmFolder, outputTMXfile)
if createTMRes.Success = False then
   MsgBox createTMRes.ShortErrorMessage
else
   MsgBox "The TM was exported."
end if

end if
Just copy that script into a text file, rename the extension to *.vbs and you have a double-clickable script to export a TM without opening memoQ. The TMX export is placed in the same folder where the script is executed and tagged with the date of the export.

Encouraged by this little test, I went on to tackle one of my pet peeves: the lack of muliti-file import capabilities in memoQ TMs. Trados Studio has no problem importing a folder full of TMX files to a TM in one go, but with memoQ one must import each TMX file - painfully - one at a time. The pain is felt quite severely if, for example, you are a former OmegaT user with a legacy of 300+ TMX files from your old projects.

So I wrote another little script which allows me to drag and drop any number of TMX files onto its icon and have them all import to the specified TM. This is a rather crude example for just one set of had-coded sublanguages (DE-DE and EN-US). The API currently does not allow sublanguages to be ignored for the import. Adapt this to use your relevant sublanguages if you like:
'
' memoQ TMX import macro
' drag & drop TMX files onto the script icon
'
tmFolder = InputBox("To which TM should the TMX file(s) be imported?")
If tmFolder <> "" Then

' The path where all my memoQ TMs are stored
standardTMpath = "E:\Working databases\MemoQ\TMs\"

'build absolute path
tmFolder = standardTMpath & tmFolder

' Create the ServiceFactoryScripting object and TM service
Set objSFS = CreateObject("MemoQ.ClientService.ServiceFactoryScripting")
Set svcTM = objSFS.CreateTMService

' Set import options parameters
Set objImportOptions = CreateObject("MemoQ.ClientService.TMImportOptionsScripting")
objImportOptions.TMXSourceLanguageCode = "ger-de" 
objImportOptions.TMXTargetLanguageCode = "eng-us"  
objImportOptions.TradosImportOptimization = False
objImportOptions.DefaultValues = Null
objImportOptions.DefaultsOverrideInput = False

  Set objArgs = WScript.Arguments
  For I = 0 To objArgs.Count - 1
    tmxfile = objArgs(I)
    logFileName = tmFolder & "_" & date() & "_" & "importlog." & I & ".txt"

    Set returnvalue = svcTM.ImportFromTMX(tmFolder, tmxfile, objImportOptions, logFileName)
    If returnvalue.Success = False Then
        MsgBox returnvalue.ShortErrorMessage
    Else
        MsgBox "No errors in the import of " & tmxfile & ". See the log file at: " & logFileName
    End If
  Next

end if

Source: http://www.translationtribulations.com