Enforcing good typography with Play Framework

Straight quotation marks and apostrophes (", ') are easy to type but typographically they aren’t so great:

Straight quotes come to us from the type­writer. In tra­di­tional print­ing, all quo­ta­tion marks were curly. But type­writer char­ac­ter sets were lim­ited by me­chan­i­cal con­straints and phys­i­cal space. By re­plac­ing the curly open­ing and clos­ing quotes with am­bidex­trous straight quotes, two slots be­came avail­able for other characters.

Word proces­sors are not lim­ited in this way. You can al­ways get curly quotes. Com­pared to straight quotes, curly quotes are more leg­i­ble on the page and match the other char­ac­ters bet­ter. There­fore, straight quotes should never, ever ap­pear in your documents.

The same applies to the web. We should prefer curly quotation marks (“—”, ‘—’) and apostrophes (’). Unfortunately, it can be easy to type the straight characters and forget to replace them with their curly equivalents. When using a text editor or an IDE, we can’t rely on the smart-quotes feature of a word processor to replace them for us automatically. We can improve the situation in a Play Framework project by writing a Specs2 unit specification to forbid the use of " and ' in the English messages file. This technique requires us to externalize our messages, but that’s not such a bad thing because doing so is a good idea anyway.

Here’s the unit specification:

Now our tests will fail if any of our messages contain straight quotes.

Leave a Reply

Your email address will not be published. Required fields are marked *