Try $LANG instead of locale.getlocale()

Avoids a crash if getlocale() returns (None, None).