Select language and language direction based on order in header

We guess which language gettext will choose by iterating over
the languages in the Language header and selecting the first
one we support. We assume a user will prioritize languages in
their browser. We then render the page using the selected
language, or English if it is no available. Bug fix on #9157.

(cherry picked from commit a31c592eadd72a659f22497f66e77fb90c6c207b)
Signed-off-by: Isis Lovecruft <isis@torproject.org>

    Taken from branch 'sysrqb/bug9157_r2_rebased'.