# django-lang [![PyPi license](https://img.shields.io/pypi/l/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
[![PyPi status](https://img.shields.io/pypi/status/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
[![PyPi version](https://img.shields.io/pypi/v/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
[![PyPi python version](https://img.shields.io/pypi/pyversions/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
[![PyPi downloads](https://img.shields.io/pypi/dm/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
[![PyPi downloads](https://img.shields.io/pypi/dw/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
[![PyPi downloads](https://img.shields.io/pypi/dd/django-lang.svg)](https://pypi.python.org/pypi/django-lang)
## GitHub ![GitHub release](https://img.shields.io/github/tag/DLRSP/django-lang.svg) ![GitHub release](https://img.shields.io/github/release/DLRSP/django-lang.svg)
## Test [![codecov.io](https://codecov.io/github/DLRSP/django-lang/coverage.svg?branch=main)](https://codecov.io/github/DLRSP/django-lang?branch=main) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/DLRSP/django-lang/main.svg)](https://results.pre-commit.ci/latest/github/DLRSP/django-lang/main) [![gitthub.com](https://github.com/DLRSP/django-lang/actions/workflows/ci.yaml/badge.svg)](https://github.com/DLRSP/django-lang/actions/workflows/ci.yaml)
## Check Demo Project
* Check the demo repo on [GitHub](https://github.com/DLRSP/example/tree/django-lang)
## Requirements
- Python 3.8+ supported.
- Django 3.2+ supported.
## Setup
1. Install from **pip**:
```shell
pip install django-lang
```
2. Modify `settings.py` by adding the app to `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
# ...
"lang",
# ...
]
```
3. Modify `settings.py` by adding the app to `INSTALLED_APPS`:
``` python title="settings.py" hl_lines="12"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(PROJECT_DIR, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"lang.context_processors.from_settings",
],
},
},
]
```
4. Modify your project's base template `base.html` to include language's switcher styles:
```html
<head>
...
<link rel="stylesheet" type="text/css" href="{% static 'lang/css/nav-link.css' %}">
...
</head>
```
5. Modify your project's base template `base.html` to include attributes using `translate_url` template's tag:
```html
<head>
...
<meta name="language" content="{{ LANGUAGE_CODE }}" />
{% include "hreflang.html" %}
...
</head>
```
6. Modify your project's nav template `nav.html` to include language's switcher:
```html
<nav class="navbar">
...
<ul class="nav navbar-nav">
{% include "nav-link.html" %}
</ul>
...
</nav>
```
## Run Example Project
```shell
git clone --depth=50 --branch=django-lang https://github.com/DLRSP/example.git DLRSP/example
cd DLRSP/example
python manage.py runserver
```
Now browser the app @ http://127.0.0.1:8000
## References
- [brainstorm.it](https://brainstorm.it/snippets/django-language-switching/) - Language's switching
- [hakibenita.com](https://hakibenita.com/django-multi-language-site-hreflang) - Url's translation for "hreflang" html's attributes
Raw data
{
"_id": null,
"home_page": "https://github.com/DLRSP/django-lang",
"name": "django-lang",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "django",
"author": "DLRSP",
"author_email": "dlrsp.dev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f0/72/e2d759e460c87c77fa686412da439fe887807e1308dd8a093ee2d0fd8755/django-lang-0.4.2.tar.gz",
"platform": null,
"description": "# django-lang [![PyPi license](https://img.shields.io/pypi/l/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n\n[![PyPi status](https://img.shields.io/pypi/status/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n[![PyPi version](https://img.shields.io/pypi/v/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n[![PyPi python version](https://img.shields.io/pypi/pyversions/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n[![PyPi downloads](https://img.shields.io/pypi/dm/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n[![PyPi downloads](https://img.shields.io/pypi/dw/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n[![PyPi downloads](https://img.shields.io/pypi/dd/django-lang.svg)](https://pypi.python.org/pypi/django-lang)\n\n## GitHub ![GitHub release](https://img.shields.io/github/tag/DLRSP/django-lang.svg) ![GitHub release](https://img.shields.io/github/release/DLRSP/django-lang.svg)\n\n## Test [![codecov.io](https://codecov.io/github/DLRSP/django-lang/coverage.svg?branch=main)](https://codecov.io/github/DLRSP/django-lang?branch=main) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/DLRSP/django-lang/main.svg)](https://results.pre-commit.ci/latest/github/DLRSP/django-lang/main) [![gitthub.com](https://github.com/DLRSP/django-lang/actions/workflows/ci.yaml/badge.svg)](https://github.com/DLRSP/django-lang/actions/workflows/ci.yaml)\n\n## Check Demo Project\n* Check the demo repo on [GitHub](https://github.com/DLRSP/example/tree/django-lang)\n\n## Requirements\n- Python 3.8+ supported.\n- Django 3.2+ supported.\n\n## Setup\n1. Install from **pip**:\n ```shell\n pip install django-lang\n ```\n2. Modify `settings.py` by adding the app to `INSTALLED_APPS`:\n ```python\n INSTALLED_APPS = [\n # ...\n \"lang\",\n # ...\n ]\n ```\n3. Modify `settings.py` by adding the app to `INSTALLED_APPS`:\n ``` python title=\"settings.py\" hl_lines=\"12\"\n TEMPLATES = [\n {\n \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n \"DIRS\": [os.path.join(PROJECT_DIR, \"templates\")],\n \"APP_DIRS\": True,\n \"OPTIONS\": {\n \"context_processors\": [\n \"django.template.context_processors.debug\",\n \"django.template.context_processors.request\",\n \"django.contrib.auth.context_processors.auth\",\n \"django.contrib.messages.context_processors.messages\",\n \"lang.context_processors.from_settings\",\n ],\n },\n },\n ]\n ```\n4. Modify your project's base template `base.html` to include language's switcher styles:\n ```html\n <head>\n ...\n <link rel=\"stylesheet\" type=\"text/css\" href=\"{% static 'lang/css/nav-link.css' %}\">\n ...\n </head>\n ```\n5. Modify your project's base template `base.html` to include attributes using `translate_url` template's tag:\n ```html\n <head>\n ...\n <meta name=\"language\" content=\"{{ LANGUAGE_CODE }}\" />\n {% include \"hreflang.html\" %}\n ...\n </head>\n ```\n6. Modify your project's nav template `nav.html` to include language's switcher:\n ```html\n <nav class=\"navbar\">\n ...\n <ul class=\"nav navbar-nav\">\n {% include \"nav-link.html\" %}\n </ul>\n ...\n </nav>\n ```\n\n\n## Run Example Project\n\n```shell\ngit clone --depth=50 --branch=django-lang https://github.com/DLRSP/example.git DLRSP/example\ncd DLRSP/example\npython manage.py runserver\n```\n\nNow browser the app @ http://127.0.0.1:8000\n\n## References\n\n- [brainstorm.it](https://brainstorm.it/snippets/django-language-switching/) - Language's switching\n- [hakibenita.com](https://hakibenita.com/django-multi-language-site-hreflang) - Url's translation for \"hreflang\" html's attributes\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Django application to provide useful utils and reusable parts of code for multi-languages sites.",
"version": "0.4.2",
"project_urls": {
"Homepage": "https://github.com/DLRSP/django-lang"
},
"split_keywords": [
"django"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "59f1525fcf13bfca9846bf18d455b32db43e0a7602260664c9dc31f00764e6d0",
"md5": "725f604d6cf2deb9926f045e0d591467",
"sha256": "11fb3000ea562889b9520ab0afa61349ad57cf5d1c0a162168c6ee348e35cd64"
},
"downloads": -1,
"filename": "django_lang-0.4.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "725f604d6cf2deb9926f045e0d591467",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.8",
"size": 7797,
"upload_time": "2024-04-05T20:26:00",
"upload_time_iso_8601": "2024-04-05T20:26:00.862553Z",
"url": "https://files.pythonhosted.org/packages/59/f1/525fcf13bfca9846bf18d455b32db43e0a7602260664c9dc31f00764e6d0/django_lang-0.4.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f072e2d759e460c87c77fa686412da439fe887807e1308dd8a093ee2d0fd8755",
"md5": "58c6a7975e3bfabe9251383dba0eb90a",
"sha256": "7bde61806b3a4dc88c9691b0937980bfc4aa6a888e8f243ce515adfa2cce87dd"
},
"downloads": -1,
"filename": "django-lang-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "58c6a7975e3bfabe9251383dba0eb90a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 14983,
"upload_time": "2024-04-05T20:26:02",
"upload_time_iso_8601": "2024-04-05T20:26:02.677100Z",
"url": "https://files.pythonhosted.org/packages/f0/72/e2d759e460c87c77fa686412da439fe887807e1308dd8a093ee2d0fd8755/django-lang-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 20:26:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DLRSP",
"github_project": "django-lang",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "django-lang"
}