digitalbiblesociety/browserbible-3 — pull request #26 by alerque (2014-07-05 21:52:04+00:00)
Title: Add hyphenation and justification as layout options

This PR depends on #22 which should be merged first. It will also have a minor conflicts with #25. One one or the other of these is merged I am happy to fix that conflict to in merges cleanly, but I wanted the PR's to be kept separate for easy review and discussion of the features introduced.

Sadly Chrome is left out of the party, but Firefox, Safari and Internet Explorer all have pretty decent hyphenation dictionaries for a number of languages now. This is a huge help in making use of space is a narrow-column environment like this app ends up being if you opt to view a couple versions at once. This set of changes should enable use of that function.

The tricky part here is that in order for this to work, the HTML `lang=` attribute has to be set correctly. Most browsers now want the IANA language codes, not the ISO-639-2 codes that BB seems to have been hard coded with up to this point. Even tricker, many Bible formats use the 3+ character ISO codes instead of the "shortest unambiguous" model of the IANA, making easy transition between them kind of tricky.

My experience with node is limited to this afternoon hacking on this, so I might have implemented this all wrong, but basically I setup a conversion table to convert the language codes coming in from Bible formats to the ones we need to make browsers actually understand what's going to using a just-in-time technique right before the HTML attribute is generated.

As an extension of this, once decent hyphenation is in place, justified text columns starts to make a lot more sense. What has a typographical suicide without it now actually doesn't look half bad and is a reasonable option to give. Whether is should be the default or not could be a point for discussion. I didn't spend too much time an the actual selector widget because I wasn't sure I was even on the right track. Might it be better to put this under the font style settings instead of with the content selectors?