Those dumb smart quotes…

#01Since Studio 2014 was launched it’s been interesting to see what some users were waiting for.  Did they want the Quickmerge, Alignment, AutoSave, improved navigation, blistering speed, automatic concordance search, improved filters, enhanced locking functionality, custom TM user ID, improvements to the term recognition threshold, more options in the display filter, auto-substitution for acronyms and a host of other improvements?  No… and I genuinely don’t mean this in a mean way… it seems for some users an easier way to handle typographical quotes is the order of the day and this hasn’t radically changed since TagEditor.

I’m sure I don’t have to go into detail on what these are, but basically when you type into a segment and use quotation marks your computer is probably going to use straight quotes like this, often referred to as “dumb” quotes:

#06

When what’s normally preferred is this, often referred to as “smart’ quotes:

#07

So how do you handle these in Studio?  I thought it was worth a quick article to show you how using three different methods:

  1. QuickInserts
  2. Search & Replace
  3. AutoHotkey

Let’s start with QuickInserts.

QuickInserts

Studio has the concept of QuickInserts which are a mechanism for being able to add characters, text, symbols or tags into your translation as you work as placeables or tag pairs.  You can read more on these in the product help here:

About customising the QuickInsert Group

The basic idea is that you have a button on the toolbar that when clicked, or when you use a keyboard shortcut for it, will insert the items you wish.  Each filetype requires it’s own QuickInserts because not all filetypes support the same type of things you may add in there.  For example, you may decide to add tags that represent the code to control something in an XML file and this may cause a problem if you used this in an IDML or another type of XML document for example.

In addition, some filetypes already come with some QuickInserts built in.  So if I look at a QuickInsert Group for a Word file I see this:

#02

So this already has QuickInserts for two types of quotes built in and the one I’m hovering over is the smart quotes.  Note that there is a keyboard shortcut for this as well, Ctrl+Shift+6.

If I open an IDML or XML file for example then you’ll find that these smart quotes are not there.  So you would have to add them.  To do this you open the Filetypes Options, choose the appropriate filetype and then QuickInsert.  In this image below you can see where I have already added one for the smart quotes:

#04

The editing window for this is very simple and looks like this, where the only choice you really have is to decide whether you want this to be a placeable or a tag pair and whether you want it on the toolbar or not.  I’ve chosen a tag pair which means I can insert both quotes together and type my text between as I translate… or I can highlight the word and then press the QuickInsert to have the smart quotes added either side of the highlighted word:

#03

Once I’ve added it my QuickInsert Group for an IDML file looks like this:

#05

The important thing to note here is that I once again have a keyboard shortcut, but note that it’s now different to the one I have for Word… this time it’s Ctrl+Shift+4.  So this means I’d have to either remember different shortcuts for each filetype, or use the mouse.

So using QuickInserts for something that you may have to use a lot in different filetypes may not be the most attractive option.  If you work mainly in one or two formats then it could be the easiest method for you.

One other important point to note about using QuickInserts is that if the file has been prepared for you already, so you receive the SDLXLIFF or a Project package, and the person who prepared the file for you did not add smart quotes to their filetype before preparing the work then you will have to add them again in Project Settings even if you already have them in your own filetypes.

Search & Replace

This solution, whilst a little geeky, has its merits.  If you receive a bilingual SDLXLIFF file, or Studio package that has already been translated and you are asked to review it then you may have to deal with the situation where dumb quotes have been used instead of smart quotes.  In this case it may be easier to search and replace the quotes in one go rather than painfully replace them all one at a time.

Using a text based search and replace this would not be possible because the opening and closing quotes are different… or at least you’d have to do two runs.  One to find a space followed by a dumb quote and then replace this with a space followed by an opening quote.  Then you search for a dumb quote followed by a space or some other punctuation and replace it with a closing quote.

But a more elegant solution is to use regular expressions.  So you can search for this:

(\s)"(.+?)"

And then replace with this:

$1“$2”

The expression itself is not too complicated.  The search looks for a space followed by a dumb quote and stores the space in a the first back reference.  Then it does a “lazy” search for anything apart from a line break until it reaches the closing dumb quote and stores what it finds (the words between the quotes) in the second back reference.

The replace recalls the first back reference and adds the opening smart quote.  Then recalls the second back reference and adds the closing smart quote.

But you can check out this article for an explanation of how you use search and replace regular expressions in Studio:

Search and replace with Regex in Studio – Regular Expressions Part 3

AutoHotkey

This is actually my personal favourite solution to this issue.  I like this best of all because this allows me to use typographical quotes wherever I am writing, and not just in Word or Studio.  You may have read this article I wrote called AutoCorrect… for everything! which explains how to use AutoHotkey so you can have your Word autocorrect lists available for you in Studio, or anywhere else.  If you did, and if you implemented it, then you’re half way there already.

All you need to do is add a couple of lines to the script you already have:

;----------------------------------------------------
; Replace dumb quotes with smart quotes as you type.
;----------------------------------------------------
:*?:" ::
Send ”%A_Space%
Return
:*?: ":: “

This is a simple script that uses regex to simply replace a dumb quote before a space with the closing smart quote, and a dumb quote after a space with an opening smart quote as you type.  So it’s a little like the autocorrect in Word except it works everywhere.  I thought a short video would be useful here so you can see how this works in practice as it may encourage you to have a go… and I showed all three methods in a couple of minutes.

So I really like this solution because it’s yet another place where you can see how useful learning a little about regular expressions can be, and because it provides a solution to the dumb smart quote issue that can be used in any application that supports typographical quotes!

So I hope this is a useful article for anyone wondering how to deal with smart quotes in Studio or anywhere else.

29 comments
  1. Funny, I was just thinking yesterday how useful it would be if only Trados Studio handled quotes in a way that mixes Word’s and PSPad’s approaches. In Word, you just type regular dumb quotes, and they get replaced with smart quotes, as long as you have the relevant setting on. In PSPad, you type one dumb quote, a second one is automatically entered for you, and the cursor stays between them for you to type what’s inside the quote.

    Now, if only Trados Studio would a) allow you to choose what quotes you prefer to use (both project- and settings-wise), and b) type the closing quote for you… That would be a huge time saver. Of course, there are exceptions when you do not want this to happen, such as with inches (PSPad treats starting a quote without a space first as an exception). Or when nesting quotes, as in Spanish we use first «», then “” and only then ʼʽ (in my texts, this very rarely happens). But all in all, mixing Word’s and PSPad’s approaches would be awesome.

    Since I heartily dislike QuickInserts (for the reasons you mention), I prefer not to run ad-hoc regex S&R (I would need macros to avoid repetition), and I find AutoHotkey too time-consuming, I simply use Type It Easy, a software that lets you EASILY create additional keyboard layouts that work in all of Windows.

    • Nice… I haven’t seen this one, although there are many like this… I think Phrase Express and AceText do similar things. I think I still prefer AHK for this though because I don’t need a shortcut at all… it works just like AutoCorrect in Word. But as a tool for providing consistent keyboard shortcuts for different types of typographical characters Type It Easy looks good.

    • For the preferred Spanish quotes «», the AutoHotkey script would be like this:

      ;—————————————————-
      ; Replace dumb quotes with double angle quotes as you type.
      ;—————————————————-
      :*?:” ::
      Send »%A_Space%
      Return

      :*?: “:: «
      Return
      ;—————————————————-

      I’ll probably coding also a simple script and dialog box (both in AutoHotkey) to quickly change the quote I need to use (dumb, smart, or double angle quote).

      Thanks for the script, Paul, we were just using the default straight quotes in Studio because there wasn’t an easy way to to type or convert them!

      Regards,

      … Jesús Prieto …

      • Excellent use of AHK Jesús, thanks for sharing your edits.

  2. Some quotes on the quickinsert tab for the docx format are indeed dumb. There is a pair of quotes which could be useful for Polish but, the upper closing one is the other way round, i.e. it is „“ and should be „” for Polish. Fortunately Polish users can use the marvellous keyboard driver called Akcent which is free and has the Polish smart quotes built in. By the way, can the out-of-the-box quickinsert buttons be removed, if I have no use for some of them?

    • Not yet… but this will change when the way QuickInserts are managed in a future release.

  3. In the same vein I’d also ask for a “geeky” way to enter special characters, available in MS Word, i.e. you type the hex code directly in Word, press Alt+X and presto/voila! the special character appears. Is anything like that planned for Studio?

    • Hmnn… doesn’t sound a lot different to using Alt+decimal code which works just fine in Studio.

  4. Excellent solutions. Upon experimentation with Studio 2011 and Greek/French quotes («»), I could add the tag pair in quick insert; however, strange things happened.
    1. When adding the QuickInsert tag through Tools >Options > File Type it would not be listed when clicking the QuickInsert settings icon on QuickInsert menu and vice versa (as if these were two different functions altogether).
    2. Although I had selected “Display on Toolbar” it was not displayed. Had it been displayed, I would have also wanted to assign a shortcut to it (no such option appears).

  5. If you add through tools – options it will be available in future projects, in the current project you have to go to project settings.

  6. brunoantonini said:

    Excellent post, as always. I also love Autohotkey and the elegant solution described here,
    However, when quotes need to be changed afterwards, for example when a reviewer has to change straight quotes into smart ones to comply with guidelines, etc, the regex search and replace approach is really convenient.
    The only risk I see is with tags (formatting and non-formatting). The find regex might be greedy enough to include tags that are not reinserted back, or at least this is what I noticed.
    You might have a case like this:

    For more information see Tag“Excellent post by Paul Filkin on dumb/smart quotes”Tag.
    After search and replace you might have:
    For more information see “Excellent post by Paul Filkin on dumb/smart quotes”GhosttagTag.
    Smart quotes but with a zombie opening tag.
    This is the case where I tested more consistent results. In other similar cases, like:
    For more information see “Excellent post by Paul Filkin on dumb/smart quotes”.
    I had intermittent results, for example with non-formatting tags the regex doesn’t match (when both tags are inside the dumb quotes).
    Or tags might be removed in similar occurrences.
    Is there any way to make the regex tag conscious?

  7. Another great option, inline with the AHK concept described by Paul, is to use a text expansion software such as Breevy (http://www.16software.com/breevy; my personal favorite) or PhraseExpress (http://www.phraseexpress.com/) for Windows, both (and others) work similar to the quite renowned TextExpander: on the Mac. Both are not free, but well worth the investment if used often, and are very easy to set up and use for those who are a bit deterred by scripting.
    Not only that one can define “abbreviations” to shorthand canned responses, insert special characters and other repetitive typing tasks, they can both import Word’s AutoCorrect dictionaries and used as a system-wide AutoCorrect-text expansion/replacement tool.

  8. Hi Paul,

    I’ve tried your suggestion of using AutoHotkey to remedy the QuickInsert shortcomings. I’ve found a way to automatically replace the single straight quote with a single curly quote to obtain a “real” apostrophe:

    ;——————————————————————————
    ; Apostrophe
    ;——————————————————————————
    :*?:'::’

    But the problem with this is that it would interfere with adopting the solution you suggest to have “smart” open and close single quotes.

    Do you have a AHK suggestion for replacing a single straight quote with an apostrophe, but a pair of them with the appropriate open and close single smart quotes?

    • I’ll have a play when I get a few mins… but in the meantime I wonder if the order you have these added in AHK plays a part. I have as follows and all three work fine.

      ;——————————————————————————
      ; Replace dumb quotes with smart quotes as you type.
      ;——————————————————————————
      :*?:" ::
      Send ”%A_Space%
      Return
      :*?: ":: “

      ;——————————————————————————
      ; Replace dumb single quotes with smart single quotes as you type.
      ;——————————————————————————
      :*?:' ::
      Send ’%A_Space%
      Return
      :*?: ':: ‘

      ;——————————————————————————
      ; Apostrophe
      ;——————————————————————————
      :*?:'::’

      • Hi Paul, this works, for single quotes, double, and the apostrophe – so long (for the quotes) one uses the American convention of closing the quotes after the punctuation “like this.” Unfortunately, when we put the punctuation after the closing quotes “like this”, the closing quote remains a straight (not curly) quote.

        Now, to make it perfect – any suggestion on how to modify this macro to handle closing quotes followed by a punctuation mark?

    • About your question: “Now, to make it perfect – any suggestion on how to modify this macro to handle closing quotes followed by a punctuation mark?” (it looks I can only answer here):

      Try this script for the closing quotes:
      :?:”::»
      Return

      And leave unchanged the starting ones:
      :*?: “:: «
      Return

      • Nice solution Jesús. I actually asked for help on the AHK forum because I can’t solve this completely myself. If you start a new line with quotes then the opening quote won’t change. I’m sure it’s a simple thing… but at least you solved the requirement from Riccardo. Thanks.

      • Hi Paul,

        This script will make it:

        ;————————————————————————————
        ; Replace dumb quotes using a boolean variable
        ; First quote entered will be the starting quote, next the closing, next the starting, and so on…
        ; If the quote is not the intended one, just delete it and press again the key “. The new entered will be fine…
        ;————————————————————————————
        :*?:”::
        if (finalQuotes=false)
        {
        Send »
        finalQuotes:=true
        }

        else
        {
        Send «
        finalQuotes:=false
        }
        Return

      • Very clever… clearly I have a lot to learn here! I redid it for the dumb/smart quotes discussed as follows:

        ;——————————————————————————
        ; Replace dumb quotes using a boolean variable
        ; First quote entered will be the starting quote, next the closing, next the starting, and so on…
        ; If the quote is not the intended one, just delete it and press again the key “. The new entered will be fine…
        ;——————————————————————————
        :*?:"::
        if (finalQuotes=false)
        {
        Send ”
        finalQuotes:=true
        }

        else
        {
        Send “
        finalQuotes:=false
        }
        Return

        Thanks Jesús, this is very helpful for us mere mortals!

  9. Hi Paul, thanks for the tip! I tried to add single quotes too (with the script below), but have run into a problem. Now all things like: Michael’s … become: Michael‘s (instead of Michael’s)

    Any idea how to edit the script? I think what needs to be done is change the part of the script that converts a single straight quote in a word like: Michael’s … into a curly one, so that it doesn’t do anything if the quote is inside of a word. Any clever ideas?

    ;——————————————————————————
    ; Replace dumb quotes using a boolean variable
    ; First quote entered will be the starting quote, next the closing, next the starting, and so on…
    ; If the quote is not the intended one, just delete it and press again the key “. The new entered will be fine…
    ;——————————————————————————
    :*?:”::
    if (finalQuotes=false)
    {
    Send ”
    finalQuotes:=true
    }

    else
    {
    Send “
    finalQuotes:=false
    }
    Return
    ;——————————————————————————
    :*?:'::
    if (finalQuotes=false)
    {
    Send ’
    finalQuotes:=true
    }

    else
    {
    Send ‘
    finalQuotes:=false
    }
    Return

    ——————————————————

    • Hi Michael, can you use something simple like this?

      ;——————————————————————————
      ; Replace dumb apostrophe
      ;——————————————————————————
      :*?:'::
      Send ’
      Return

  10. anka said:

    Hi Paul, you helped me a lot with this article. I’ve used search & replace with regular expressions in order to replace all dumb quotes in one go. There’s just one small problem left (for me at least, as I’m not smart enough to alter the regular expression accordingly): I was able to look for quotes without a space in front of them (for example quotes in brackets etc.), but how to replace them? Would you mind providing me with a solution for the right expression to use instead of “$1“$2””? Thanks a lot!

    • Hi Anka, can you confirm what you’re searching for exactly and then what you’d like it to look like? I’m bound to give you a bum steer otherwise!!

      • anka said:

        I’m searching for expressions like (“word”) and would like to replace the dumb quotes in such expressions by smart quotes. The reg ex you provided isn’t able to find and replace them since it is looking for quoted words surrounded by spaces. I have a text that is full of quoted words in brackets and would be extremely thankful if you could share a solution which is as smart as the one in your example:)

      • ok – I get it. Your problem is that the brackets need to be escaped as they have a special meaning when you search with regular expressions. You escape by putting a backslash before the bracket and then it can find the exact character you need. So try searching for this:

        \(“(\w+)”\)

        Then replace with this:

        (“$1”)

        Works nicely on my test file :-)

      • anka said:

        Thank you Paul. This one unfortunately didn’t work on my file, but maybe that is my mistake. Another, similar problem occurs with quoted words at the beginning of sentences, because in Trados segments the space between the fullstop of one sentence (=segment) and the first letter of the next sentence (=next segment) doesn’t appear. For example:

        This is the first sentence. “This word” is the beginning of the second sentence.

        Your above solution won’t find “This word”, because in a Trados segment it is not preceded by a space. I hope you’re getting what I mean. Do you have any idea how to find & replace this? Having a solution for these two cases would speed up my review of this huge amount of files even more. Thanks!

      • Hi Anka, can you email me the file and write in the email which things you want changed? I think I’m guessing too much and just providing solutions for what I think you need, as opposed to what you really need! I won’t change the file, but will explain how to do it. You can email me at pfilkin at sdl dotcom

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,972 other followers

%d bloggers like this: