'Return a locale code we support on the site using the
user\'s Accept-Language header to determine which is best. This
mostly follows the RFCs but read bug 439568 for details.'

def get_language(self):

    if ('lang' in self.request.GET):
        lang = self.request.GET['lang'].lower()
        if (lang in settings.LANGUAGE_URL_MAP):
            return settings.LANGUAGE_URL_MAP[lang]
    if self.request.META.get('HTTP_ACCEPT_LANGUAGE'):
        best = get_best_language(self.request.META['HTTP_ACCEPT_LANGUAGE'])
        if best:
            return best
    return settings.LANGUAGE_CODE
