Skip to content

Instantly share code, notes, and snippets.

View bjinwright's full-sized avatar

Brian Jinwright bjinwright

View GitHub Profile
@bjinwright
bjinwright / language.py
Last active May 17, 2017 15:43 — forked from beaufour/language.py
Django Middleware to choose language based on subdomain
import logging
from django.utils import translation
from django.conf import settings
class DomainBasedLanguageMiddleware(object):
"""
Set the language for the site based on the subdomain the request
is being served on. For example, serving on 'fr.domain.com' would
make the language French (fr).