correct bug in hyphendialog language selection

check if lang variable is defined before using it
use QLocale to detect system language

This has two advantages:
1. in systems that let the user specify an ordered list of preferred
languages, the system languages preference order is respected, instead
of just checking if the first preferred language is available;
2. on Mac OS X, when Frescobaldi is launched as an application bundle or
if the locale environment variables are not set (apparently default in
10.7+) system language is correctly retrieved.

Thanks to Stefan Vollmar for the suggestion and for his help in testing.
make Accept-Language header compliant with RFC2616

When retrieving the documentation for LilyPond, an Accept-Language HTTP
header is sent.
According to RFC2616, section 3.10, language names must be of the form
language-tag  = primary-tag *( "-" subtag )
primary-tag   = 1*8ALPHA
subtag        = 1*8ALPHA
and are case-insensitive.
compile Accept-Language HTTP header with system preferred languages

Using QLocale as the preferred method takes into account the systems
that let the user specify not only one language, but a list of preferred
languages in order of preference.
rationalize and extend the use of QLocale to all suitable places
also use abscommand() in custom engrave dialog
Merge pull request #179 from dliessi/system-language-detection

impovements in system language detection
use str.replace i.s.o re.sub, cleanup a bit, reorganize
use new lang stuff also in network/lilydoc
oops
oops
language_names should not be dependent on any other module, just python stdlib
po.preferred moved to po.setup