Skip to main content

TurboGears2 extension for detecting user language from the domain

Project description

About tgext.langdomain

tgext.langdomain is a TurboGears2 extension that supports detecting the user language from the domain it is connecting from.


tgext.langdomain can be installed from pypi:

pip install tgext.langdomain

should just work for most of the users.


To enable tgext.langdomain put inside your application config/ the following:

import tgext.langdomain

or you can use tgext.pluggable when available:

from tgext.pluggable import plug
plug(base_config, 'tgext.langdomain')


langdomain will force the language of the current request based on: Top Level Domain, SubDomain and param unless there is already a language stored into the session.

By default none of those behaviours is enabled

When plugging langdomain the following options to turn on behaviours are available:

param -> Name of the GET param used to force language, True means lang.

tld -> Dict of tld that map to a language


plug(app_cfg, 'tgext.langdomain',
       'com': 'en',
       'it': 'it'

subdomain -> Dict of subdomains that map to a language


plug(app_cfg, 'tgext.langdomain',
       'en': 'en',
       'it': 'it'

When requests are performed like it will lookup it inside the subdomain dictionary and net inside the tld dictionary.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgext.langdomain-0.0.1.tar.gz (3.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page