Skip to main content

Language switch for Django

Project description

https://travis-ci.org/stinovlas/django-lang-switch.svg?branch=devel https://codecov.io/gh/stinovlas/django-lang-switch/branch/devel/graph/badge.svg https://img.shields.io/pypi/v/django-lang-switch.svg https://img.shields.io/pypi/pyversions/django-lang-switch.svg https://img.shields.io/pypi/djversions/django-lang-switch.svg

Language switch for Django.

Installation

You can install django-lang-switch from PyPi:

$ pip install django-lang-switch

Configuration

You need to add django_lang_switch.apps.DjangoLangSwitchConfig into your INSTALLED_APPS setting. If you want to add enable language switch in django admin site, you have to add it before django.contrib.admin. Otherwise, you need to put django.contrib.admin first. If you don’t use django admin site, the order does not matter.

If you tweaked the admin/base_site.html template yourself, put this application after yours and use the template tag as described below.

You also need to include django-lang-switch urls to your ROOT_URLCONF. Example:

from django.urls import include, path

urlpatterns = [
    ...
    path('django_lang_switch/', include('django_lang_switch.urls')),
]

You can of course change the path to suit your needs.

Usage

If you just want to add language switch to django admin site, add this application to your INSTALLED_APPS as described above and you are done.

If you want to use the same switch elsewhere, add template tage lang_switch_dropdown to your template. Don’t forget to load lang_switch tag collection to your template. Example:

{% extends myapp/base_site.html %}
{% load lang_switch %}
<div id="header">
    Welcome to MyApp!
    <div class="right">
        {% lang_switch_dropdown %}
    </div>
</div>

Styling

Language switch in django admin site is already styled to fit the default design. If you want to style the lang switch yourselves, you may set css for the div.lang-switch element and its descendants.

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

django-lang-switch-0.1.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

django_lang_switch-0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file django-lang-switch-0.1.tar.gz.

File metadata

  • Download URL: django-lang-switch-0.1.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for django-lang-switch-0.1.tar.gz
Algorithm Hash digest
SHA256 fa9e98250af58d2e572abcb145150184c5a2db4f60f00eda55e1f598aab341f1
MD5 c6f46493dfe5bda8b1981adffa6727b6
BLAKE2b-256 459bf488adc44ceed6024096fe9d5aad9a32f3eafe2ba784f46925d220da1a8d

See more details on using hashes here.

File details

Details for the file django_lang_switch-0.1-py3-none-any.whl.

File metadata

  • Download URL: django_lang_switch-0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for django_lang_switch-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4bb79be0b2b7299b9b50e045c8fdd4056cd7a832f2a40400cb3a556239e2f3b2
MD5 ade8f36f2e2dfefac4c8d274d930a98a
BLAKE2b-256 705ca2766b6d922f5dce6455fddaf510102f2bbb0cc9aafa601f63b89f9f81c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page