'If request is omitted, fall back to a default locale.'

def __init__(self, request=None, locale=None):

    from kitsune.users.models import Profile
    self.request = (request or WSGIRequest({'REQUEST_METHOD': 'bogus', 'wsgi.input': None}))
    (self.locale, self.shortened_path) = split_path(self.request.path_info)
    if ((not self.locale) and request):
        if request.user.is_anonymous():
            language = request.session.get(settings.LANGUAGE_COOKIE_NAME)
            if language:
                self.locale = language
        else:
            try:
                self.locale = Profile.objects.get(user=request.user).locale
            except Profile.DoesNotExist:
                pass
    if locale:
        self.locale = locale
