Tuesday, September 29, 2015

Translating AutoCAD Drawings: TranslateCAD + Studio

Translating AutoCAD files may seem like a daunting proposition. After all, it's not an everyday file format for many of us. Luckily, there's a way to handle them with relative ease in SDL Trados Studio with the assistance of a separate program called TranslateCAD and a little file type customization via regular expressions.

1. Preparing the files

If the source files are DWGs, the first step will be converting them to DXFs, as TranslateCAD can only process files in DXF format. If AutoCAD is not available for the conversion, a free program like DraftSight will work as well.

2. Extracting text with TranslateCAD

Start TranslateCAD, navigate to the folder containing the DXF files, select all the files that need to be translated and click the Extract Text button.


TranslateCAD will create two text files for each DXF, adding "trans1" and "trans2" to the name. The "trans1" files contain the translatable text, so those are the ones to be used in Studio, while the "trans2" files should be left untouched.



3. Customizing the Studio TXT file type*

*This step will only need to be completed once if the same file type settings will be used to process future AutoCAD-based TXT files.

The TXT file produced by TranslateCAD includes some content that is not translatable text, as shown here:


Opening the file in Studio with the default TXT file type settings will result in each of those lines being included as a translatable segment. To exclude them, we can customize the file type by adding regular expressions to tell Studio to interpret that text as inline tags, and therefore non-translatable.

We can do this for all future projects and single files by going to Options > File Types > Text, or only for our active project by going to Project Settings > File Types > Text.

Once the Text file type is selected, we go to Inline tags and click the Add rule button.


When the Add inline rule window opens, we select Placeholder for the Rule Type and enter our regular expression in the Rule Opening field:


After clicking OK, the rule will be added to the list. Additional rules can be added by repeating this procedure.



These are a few examples of regular expressions that can be useful when working with AutoCAD files.

Regular Expression
Description
Sample captured text
^#+\d+#+$
A segment starting with two pound signs followed by one or more numbers and ending in two pound signs
##000001##
^\d+$
A numbers-only segment
264
^[A-Z]$
A segment consisting of a single uppercase letter
A

Once the appropriate rules have been added, we can close the Options (or Project Settings) dialog box.

A bug-related update (April 2016)
Paul Filkin has brought to my attention that there is a bug in SDL Trados Studio 2015 SR2 that causes the above procedure to fail, for which he has found a workaround. This may be helpful for anyone who comes across this issue.

Paul writes:

In the current version of Studio this doesn’t seem to work.  I’ve logged a bug and found a workaround by adding these things to the structure as opposed to inline tagging:



4. Translating the files in Studio

Now that everything is ready, we can add the TXT files to Studio, and process them as we normally would, translate them and generate the target files. Since our target files should replace the original TXT files, the name should remain unchanged and they should be placed in the same folder as the original source files.

5. Converting the translated TXT files back to DXF

Once the target TXT files are ready, we go back to TranslateCAD and use the "Join TXT files to recreate Translated DXF" feature. It's a simple matter of selecting the files we need to convert and clicking Re-Construct DXF.


TranslateCAD will produce new DXF files with "trans" appended to the name.

6. Converting the DXF files to DWG

For the final step we will need to go back to AutoCAD or DraftSight and save the DXF files as DWGs.

And that's it! This may sound complicated, but in fact, once we've set up the file type regex rules, any future files can be processed rather quickly.


Sometimes it’s the Little Things: Managing Abbreviations for Better Segmentation

One of the main sentence-level segmentation rules in Studio uses a full stop to indicate the end of a sentence and therefore the end of a segment. For most jobs, this default segmentation works well, but what if our source text looks like this?


Since Studio interprets each of those periods as the end of a sentence, our file will look like this:


If word order is different in the source and target languages, working with this file will mean entering the translation and locking each segment without confirming it, which means the new translations won’t be added to the TM, which will result in losing all concordance and propagation benefits, as well as any potential future leverage. And if the file has hundreds or thousands of segments like this, productivity can be significantly affected.

Luckily, there’s a simple solution to this: adding “ELEC.”, “HYDR.” and “SYS.” (or any relevant abbreviations, of course) to Studio’s list of recognized abbreviations. Basically, Studio will create a new segment after every period, except when that period is used as part of an abbreviation, so we can make use of this feature, as the list of abbreviations can be edited in the Translation Memory’s settings. Here’s how to do it.

First, go to your TM settings, then Language Resources > Abbreviation List, and click Edit.


This opens the Abbreviations list. Scroll to the bottom and add your abbreviations.


After clicking OK 3 times to close the TM settings window, the new abbreviations will now be recognized by the TM and therefore Studio will ignore them when segmenting a file.

Note that this new segmentation cannot be applied to an existing SDLXLIFF file, which is already segmented, so the source file will need to be processed again by either adding it to a project or opening it as a single file, using the TM that contains the new abbreviations.

After doing so, we get the following Studio file for our example above.


Much better!

As a final note, keep in mind that abbreviations are part of the Translation Memory, which means we can customize them as needed, based on our various files and projects.


Wednesday, August 19, 2015

Words Breaking Up Arbitrarily at Line End? Asian Language Rules May Be the Reason

After spending the better part of an afternoon troubleshooting some files, I'm writing this post both as a troubleshooting record for myself and to help others out there who may be facing the same issue, hoping it will save someone some time.

The Issue
I recently worked on a project involving a large number of MS Word files. The source text was in English, the files needed to be translated into Spanish. Our team used SDL Trados Studio for the translation and everything seemed to go smoothly... until we opened the target files in Word and started seeing some odd word breaks at the end of lines. Words were breaking up arbitrarily, as shown in the example below.


The Source of the Issue
As it turns out, even though the documents provided for translation were in English, the original files had been created in Korean. This means that Asian language features were carried over in the document paragraph styles.

Looking at the style for the odd-looking text revealed three settings I didn't remember having seen before: "Allow text to wrap in the middle of a word", "Don't adjust space between Latin and Asian text" and "Don't adjust space between Asian text and numbers".



Of these, "Allow text to wrap in the middle of a word" seemed the likely culprit, but my usual paragraph settings didn't offer a way to disable it. To be able to do this, Asian Language Support had to be installed on my computer.

The Solution
The first thing I had to do was download an Asian language pack. I chose Korean because that was the language used when creating these documents.

To download a language pack in Windows 10, I went to my computer clock on the taskbar, clicked on it and selected Date and time settings at the bottom, then Region & language in the window that opens. On the right pane, under Country and region, I could see my installed languages, and clicked on the "+" next to "Add a language". Then found Korean and clicked on it. After a couple of minutes, when I could see "Language Pack Available" next to Korean, I clicked on it and then "Options". At this point the language pack is not yet installed on the computer, so the last button to click before this happens is the "Download" button under Language Options.

Once this was complete, I shut down and restarted Word (I'm using Word 2013).

I then opened one of my problem documents in Word, and right-clicked on the "Normal" style (Home tab - Styles group) and selected Modify. in the Modify Style window, I then clicked on Format - Paragraph. The dialog box that opens now has a new tab: "Asian Typography". And the second setting on this new tab is "Allow Latin text to wrap in the middle of a word".


As soon as I uncheck the box, text wraps correctly.


Note: This setting may need to be changed for each individual style that shows this issue.


Thursday, July 23, 2015

A Collection of Regular Expressions for the Regex Match AutoSuggest Provider

The Regex Match AutoSuggest Provider app is one of my absolute favorite add-ons for Studio, and it has been a great reason to continue learning about regular expressions.

What does it do?
Based on rules that you can set up on-the-fly, the plug-in offers AutoSuggest proposals, as shown in this example:


Depending on how you set up your rules, the plug-in can:

  1. Offer an autosuggestion that is exactly the same as the word or phrase found in your source segment, so all you have to type is the first letter, instead of the whole thing. For example, you can have a rule that will suggest an entire phone number string, such as "1-800-012-3456", as soon as you type the first number.
  2. Offer an autosuggestion where the source text has been replaced by its translation. So, for example, when "July 22" is found in the source, "22 de julio" will be offered as an autosuggestion as soon as you type the first "2".
What do you need to use it?
First, you need to download the plug-in from the SDL Open Exchange and install it. The Regex Match AutoSuggest Provider is available for Studio 2014 (and soon for Studio 2015).

Once installed, it is found under the View tab in Studio. Clicking on the button will open the pane where you can start entering your RegEx Entries.

The developer provides a very clear explanation of the set-up here.

You can safely close this pane when you're not entering any new rules, and open it again as needed. I find it useful to have it open as I work, so I can quickly add new rules as I need them.

Some examples
Here are some rules and examples of their application, with a disclaimer: I'm a novice regex user, so please don't expect these to be the most elegant or sophisticated regex rules out there. In venturing into creating regex rules to use with Studio, I decided to follow Paul Filkin's advice about "economy of accuracy" and move past my worry of creating clunky regular expressions, so you may find some clunkiness here, but hopefully these will be useful either as they are, or as a starting point to achieve something else.

Date: First day of the month

Description
Regex Pattern
Replace Pattern
Dates: First of month Ex: July 1, 2015 --> 1° de julio de 2015
(#Months#)\s(1|1st),\s(\d{4})
1° de $1 de $3
 Note: The "#Months#" part of the expression is a reference to a variable from a list, in this case, the names of the months, another very clever feature of the plug-in. You can watch Paul Filkin's video Manipulating Dates with RegexMatch AutoSuggest for a clear explanation of this feature.



Date: Full date


Description
Regex Pattern
Replace Pattern
Dates: July 22, 2015 ---> 22 de julio de 2015
(#Months#)\s(\d{1,2}),\s(\d{4})
$2 de $1 de $3



Date: DD/MM/YY 

Description
Regex Pattern
Replace Pattern
Dates: 8/7/15 to 7/8/15
(\d{1,2})/(\d{1,2})/(\d{2})
$2/$1/$3



Date: Month and Year

Description
Regex Pattern
Replace Pattern
Month and year  Ex. July 2015 --> julio de 2015
(#Months#)\s(\d{4})
$1 de $2



Date: Day and Month

Description
Regex Pattern
Replace Pattern
Month and day w/o year. Ex. July 22 --> 22 de julio
(#Months#)\s(\d{1,2})(?!.*\d{4})
$2 de $1



1x

Description
Regex Pattern
Replace Pattern
Ex: 1x ---> 1 vez
\b1x\b
1 vez



50x

Description
Regex Pattern
Replace Pattern
Ex: 10x ---> 10 veces - excluding "1x"
(?!1x)(\d{1,2})x
$1 veces



5-6

Description
Regex Pattern
Replace Pattern
Ex: 8-10 ---> de 8 a 10
(\d{1,2})-(\d{1,2})
de $1 a $2



1-800 number

Description
Regex Pattern
Replace Pattern
Full phone numbers Ex. 1-800-123-1234
\d-(\d{3})-(\d{3})-(\d{4})
$0



8:00 a.m.

Description
Regex Pattern
Replace Pattern
Time plus a.m. or p.m. Ex. 9:00 a.m.
(\d{1,2}:\d{2})\s(a\.|p\.)m\.
$0



Numbers with backslashes


Description
Regex Pattern
Replace Pattern
Numbers with points and slashes Ex. 36.5/93
\d+\.\d+/\d+
$0



Percentages

Description
Regex Pattern
Replace Pattern
Percentages  Ex. 35%
\d{1,3}%
$0



Trademark names

Description
Regex Pattern
Replace Pattern
Words with TM Ex. AnyBrand™
\w+™
$0



Registered names

Description
Regex Pattern
Replace Pattern
Words with (R) Ex. AnyBrand®
\w+®
$0



Watch a video demonstration of the above here.


And here's the full list of the examples shown above.
Description
Regex Pattern
Replace Pattern
Dates: First of month Ex: July 1, 2015 --> 1° de julio de 2015
(#Months#)\s(1|1st),\s(\d{4})
1° de $1 de $3
Ex: 1x ---> 1 vez
\b1x\b
1 vez
Ex: 10x ---> 10 veces - excluding "1x"
(?!1x)(\d{1,2})x
$1 veces
Dates: July 22, 2015 ---> 22 de julio de 2015
(#Months#)\s(\d{1,2}),\s(\d{4})
$2 de $1 de $3
Ex: 8-10 ---> de 8 a 10
(\d{1,2})-(\d{1,2})
de $1 a $2
Dates: 8/7/15 to 7/8/15
(\d{1,2})/(\d{1,2})/(\d{2})
$2/$1/$3
Month and day w/o year. Ex. July 22 --> 22 de julio
(#Months#)\s(\d{1,2})(?!.*\d{4})
$2 de $1
Full phone numbers Ex. 1-800-123-1234
\d-(\d{3})-(\d{3})-(\d{4})
$0
Time plus a.m. or p.m. Ex. 9:00 a.m.
(\d{1,2}:\d{2})\s(a\.|p\.)m\.
$0
Numbers with points and slashes Ex. 36.5/93
\d+\.\d+/\d+
$0
Month and year  Ex. July 2015 --> julio de 2015
(#Months#)\s(\d{4})
$1 de $2
Percentages  Ex. 35%
\d{1,3}%
$0
Words with TM Ex. AnyBrand™
\w+™
$0
Words with (R) Ex. AnyBrand®
\w+®
$0




And that's all there is to it. What I like about the Regex Match AutoSuggest Provider is that it's easy to use (although some basic knowledge of regex is required) and it's project-independent, which means the entries are available all the time, for all files and projects, so it's a great way to customize Studio's autosuggestions to our individual needs.