Skip to content

Instantly share code, notes, and snippets.

View rbtsolis's full-sized avatar
👨‍💻

Roberth Solís rbtsolis

👨‍💻
View GitHub Profile
@rbtsolis
rbtsolis / language.py
Created October 13, 2017 19:57 — forked from beaufour/language.py
Django Middleware to choose language based on subdomain
import logging
from django.utils import translation
class SubdomainLanguageMiddleware(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).