+try:
+ DEFAULT_SITE = Site.objects.get_current()
+except:
+ DEFAULT_SITE = None
+_languages = dict(settings.LANGUAGES)
+try:
+ _languages[settings.LANGUAGE_CODE]
+ DEFAULT_LANGUAGE = settings.LANGUAGE_CODE
+except KeyError:
+ try:
+ lang = settings.LANGUAGE_CODE.split('-')[0]
+ _languages[lang]
+ DEFAULT_LANGUAGE = lang
+ except KeyError:
+ DEFAULT_LANGUAGE = None