Smart Quotes

There is a nifty function in WordPress that automagically turns so-called "straight" or "dumb" quotes into so-called “smart” or “curly” quotes. (Look at the last sentence closely: There’s a difference between the various quotation marks.)

Different languages use different quotation marks, e.g. Germans use a lower double quotation mark („) to open a quotation. The double curly quotation mark that the English use to open (“) the Germans use to close a quotation.

So built right into WordPress is the option for translators to change the look of the smart quotes in the language files. However there are two caveats which I address in the plugin “Smart Quotes”:

  • Many languages have alternative styles, depending on personal taste, industry tradition, etc., or some languages are spoken in multiple countries, but countries speaking the same language may still use different quotation marks – e.g. Germans use „…“ whereas the German-speaking Swiss use «…», but there is no special localized version of WordPress for Swiss-German (de_CH)
  • The language file does not normally get used to style the HTML <q> element

With “Smart Quotes” you can pick any arbitrary character combination that will be used both for the WordPress magic (wptexturize for those interested) and for styling the <q> element.

Download “Smart Quotes” (.zip)

After you’ve installed the plugin you can pick your quotation marks on the Writing Settings screen.

  1. Wouldn’t it be even smarter to have a plugin that changes quotes in a multilingual installation? I could do with something like that for a project that has to cater for English, French, and German readers.

  2. Tell me how you switch the language and I’ll see if and how the plugin can be adapted!

  3. Looks like a nice plugin, but it doesn’t work with WordPress 3.5.1. Is there any chance we will see an updated version?

  4. Thanks, Emma, for pointing this out. Turns out I wasn’t really paying any attention there. Updated version is available since yesterday.

  5. Thank you Martin!

  6. Hi!
    Already wrote in the WP plugin directory forums, but I’ll try again here:

    It seems that in line 63 & 64 of your smart-quotes.php you are not distiguishing between single and double quotes, but replacing both with one glyph.

    Why is that?

    Cheers,
    M

  7. Hi Martin,

    I didn’t catch your post in the WP forums. Sorry about that.

    I am not touching single quotes in lines 63 and 64. The reason I am checking both “opening curly double quote” and “opening curly quote” (or “closing…”) is that the Gettext identifiers were changed between WP 3.4 and 3.5 (or another recent version change, don’t hold me on these numbers). There is an && (“AND”) operator on the same line, and entity 8220 is a double quote.

    Hope this clarifies things!?

    Cheers,
    Martin

  8. Hi Martin,

    There appears to be a small bug when the closing quote comes after a number. Here is what is causing my problem:

    "5" produces «5″ (Spanish opening quote, wp default closing quote)

    "5" produces «5« (Spanish opening quote, Spanish opening quote again)

    It’s the same in the 2013 theme also.

    Thanks for your help!
    Tim

  9. That second “5” is inside an anchor tag, which probably isn’t obvious.

Reply

Your email address will not be published.