Just in case anyone is interested... I wrote my own middleware class to
support selecting languages from the URL itself. eg:

www.example.com - default english
www.example.com/de - same page with german trans

It was a simple copy-paste of the LocaleMiddleWare from the distro:

##################
from django.utils.cache import patch_vary_headers
from django.utils import translation
class LocaleURLMiddleware:

    def get_language_from_request (self,request):
        from django.conf import settings
        import re
        supported = dict(settings.LANGUAGES)
        lang = settings.LANGUAGE_CODE[:2]
        check = re.match(r"/(\w\w)/.*", request.path)
        if check is not None:
            t = check.group(1)
            if t in supported:
                lang = t
        return lang

    def process_request(self, request):
        language = self.get_language_from_request(request)
        translation.activate(language)
        request.LANGUAGE_CODE = translation.get_language()

    def process_response(self, request, response):
        patch_vary_headers(response, ('Accept-Language',))
        translation.deactivate()
        return response


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to