added ability to translate websites

feature/translations
KarolG 2023-06-07 04:30:00 +02:00
rodzic 81c5926261
commit 2e80c0f9b3
3 zmienionych plików z 30 dodań i 8 usunięć

Wyświetl plik

@ -30,6 +30,7 @@ INSTALLED_APPS = [
"search",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.contrib.simple_translation",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
@ -41,6 +42,7 @@ INSTALLED_APPS = [
'wagtail.contrib.modeladmin',
"wagtail",
"wagtailmenus",
'wagtail.locales',
"modelcluster",
"taggit",
"django.contrib.admin",
@ -62,6 +64,7 @@ MIDDLEWARE = [
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.security.SecurityMiddleware",
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
'django.middleware.locale.LocaleMiddleware',
]
ROOT_URLCONF = "artel.urls"
@ -77,6 +80,7 @@ TEMPLATES = [
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
'django.template.context_processors.i18n',
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
'wagtailmenus.context_processors.wagtailmenus',
@ -132,6 +136,12 @@ USE_L10N = True
USE_TZ = True
WAGTAIL_I18N_ENABLED = True
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
('en', "English"),
('pl', "Polish"),
]
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/

Wyświetl plik

@ -1,22 +1,29 @@
{% load static %}
{% load static %}
{% load menu_tags %}
{% load wagtailcore_tags %}
<div class="d-flex flex-column flex-shrink-0 p-3 mr-5" style="width: 280px;">
<img src="{% static 'images/icons/las_ruinas_PL.png' %}" class="rounded mx-auto d-block mt-3"/>
<hr>
<ul class="nav navbar-nav">
{% for translation in page.get_translations.live %}
<a href="{% pageurl translation %}" rel="alternate" hreflang="{{ translation.locale.language_code }}">
{{ translation.locale.language_name_local }}
</a>
{% endfor %}
{% for item in menu_items %}
<li class="{{ item.active_class }}">
<a href="{{ item.href }}">{{ item.text }}</a>
{% if item.has_children_in_menu %}
<button class="btn btn-toggle" data-bs-target="#ddtoggle_{{ item.link_page.pk }}" data-bs-toggle="collapse"
aria-expanded={% if item.active_class %}"true" {% else %} "false" {% endif %}
aria-expanded={% if item.active_class %}"true" {% else %} "false" {% endif %}
aria-controls="#ddtoggle_{{ item.link_page.pk }}">
<img src = "{% static 'images/icons/caret-down.svg' %}" alt="&or;"/> </button>
{% sub_menu item template="menu/custom_submenu.html" %}
{% endif %}
</li>
</li>
{% endfor %}
</ul>
</div>
@ -24,6 +31,3 @@
<hr>
<a href={% url 'cart' %} alt="Koszyk" > Koszyk </a>
</div>

Wyświetl plik

@ -1,6 +1,6 @@
from django.conf import settings
from django.urls import (
include,
include,
path
)
from django.contrib import admin
@ -10,6 +10,8 @@ from wagtail.admin import urls as wagtailadmin_urls
from wagtail import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
from django.conf.urls.i18n import i18n_patterns
from search import views as search_views
urlpatterns = [
@ -20,6 +22,12 @@ urlpatterns = [
path("store-app/", include("store.urls"))
]
urlpatterns += i18n_patterns(
path('search/', search_views.search, name='search'),
path("", include(wagtail_urls)),
path("search/", search_views.search, name="search"),
path("store-app/", include("store.urls"))
)
if settings.DEBUG:
from django.conf.urls.static import static