{"id":21919449,"url":"https://github.com/dlrsp/django-lang","last_synced_at":"2025-04-19T12:33:25.079Z","repository":{"id":202825939,"uuid":"708208795","full_name":"DLRSP/django-lang","owner":"DLRSP","description":"Django application to provide useful utils and reusable parts of code for multi-languages sites.","archived":false,"fork":false,"pushed_at":"2024-10-09T01:49:51.000Z","size":408,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-10T10:06:09.100Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DLRSP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-21T21:12:07.000Z","updated_at":"2024-09-11T08:04:57.000Z","dependencies_parsed_at":"2024-01-23T09:57:20.128Z","dependency_job_id":"a92da7f5-ceef-46b2-bcc2-809b63dd8aa3","html_url":"https://github.com/DLRSP/django-lang","commit_stats":null,"previous_names":["dlrsp/django-lang"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DLRSP","download_url":"https://codeload.github.com/DLRSP/django-lang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226979180,"owners_count":17712574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T20:07:58.436Z","updated_at":"2024-11-28T20:07:59.450Z","avatar_url":"https://github.com/DLRSP.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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    \u003chead\u003e\n        ...\n        \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"{% static 'lang/css/nav-link.css' %}\"\u003e\n        ...\n    \u003c/head\u003e\n    ```\n5. Modify your project's base template `base.html` to include attributes using `translate_url` template's tag:\n    ```html\n    \u003chead\u003e\n        ...\n        \u003cmeta name=\"language\" content=\"{{ LANGUAGE_CODE }}\" /\u003e\n        {% include \"hreflang.html\" %}\n        ...\n    \u003c/head\u003e\n    ```\n6. Modify your project's nav template `nav.html` to include language's switcher:\n    ```html\n    \u003cnav class=\"navbar\"\u003e\n        ...\n        \u003cul class=\"nav navbar-nav\"\u003e\n            {% include \"nav-link.html\" %}\n        \u003c/ul\u003e\n        ...\n    \u003c/nav\u003e\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlrsp%2Fdjango-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlrsp%2Fdjango-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlrsp%2Fdjango-lang/lists"}