From 56e80194a95901703fed63cf5066781dcbdf1848 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Fri, 8 Mar 2024 01:02:04 -0800 Subject: [PATCH 01/18] Created utils app --- utils/__init__.py | 0 utils/admin.py | 3 +++ utils/apps.py | 6 ++++++ utils/migrations/__init__.py | 0 utils/models.py | 3 +++ utils/tests.py | 3 +++ utils/views.py | 3 +++ 7 files changed, 18 insertions(+) create mode 100644 utils/__init__.py create mode 100644 utils/admin.py create mode 100644 utils/apps.py create mode 100644 utils/migrations/__init__.py create mode 100644 utils/models.py create mode 100644 utils/tests.py create mode 100644 utils/views.py diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/admin.py b/utils/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/utils/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/utils/apps.py b/utils/apps.py new file mode 100644 index 0000000..4faf4f6 --- /dev/null +++ b/utils/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class UtilsConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "utils" diff --git a/utils/migrations/__init__.py b/utils/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/models.py b/utils/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/utils/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/utils/tests.py b/utils/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/utils/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/utils/views.py b/utils/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/utils/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From 6da14aab779f4ed09432c1c95f045ff7a2929a0e Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Sat, 9 Mar 2024 19:18:56 -0800 Subject: [PATCH 02/18] Set wagtail languages as languages --- hot_osm/settings/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index bb5edc1..2b9d227 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -136,7 +136,7 @@ USE_TZ = True -WAGTAIL_CONTENT_LANGUAGES = [ +WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [ ("en", "English"), ("fr", "French"), ("es", "Spanish"), From 3ab2f9c50f24d1b05a045c89d43973157ee247c7 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Sat, 9 Mar 2024 19:42:08 -0800 Subject: [PATCH 03/18] Removed URL extension for default language --- hot_osm/settings/base.py | 2 +- hot_osm/urls.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index 2b9d227..f096898 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -126,7 +126,7 @@ # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ -LANGUAGE_CODE = "en-us" +LANGUAGE_CODE = "en" TIME_ZONE = "UTC" diff --git a/hot_osm/urls.py b/hot_osm/urls.py index 523c031..da6525b 100644 --- a/hot_osm/urls.py +++ b/hot_osm/urls.py @@ -34,5 +34,6 @@ # Alternatively, if you want Wagtail pages to be served from a subpath # of your site, rather than the site root: # path("pages/", include(wagtail_urls)), + prefix_default_language=False, ) ) From 537a7510288b46ecdc41a57c33f5a794cc6c77bb Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Sun, 10 Mar 2024 04:53:38 -0700 Subject: [PATCH 04/18] Rendered language dropdown, not yet submittable --- hot_osm/settings/base.py | 1 + .../components/nav/secondary_desktop_nav.html | 2 +- hot_osm/urls.py | 1 + utils/templates/language_switcher.html | 16 ++++++++++++++++ utils/urls.py | 9 +++++++++ utils/views.py | 10 ++++++++-- 6 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 utils/templates/language_switcher.html create mode 100644 utils/urls.py diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index f096898..0f5768d 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -74,6 +74,7 @@ "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [ os.path.join(PROJECT_DIR, "templates"), + os.path.join(PROJECT_DIR, "..", "utils", "templates"), ], "APP_DIRS": True, "OPTIONS": { diff --git a/hot_osm/templates/components/nav/secondary_desktop_nav.html b/hot_osm/templates/components/nav/secondary_desktop_nav.html index c00c667..e749267 100644 --- a/hot_osm/templates/components/nav/secondary_desktop_nav.html +++ b/hot_osm/templates/components/nav/secondary_desktop_nav.html @@ -7,7 +7,7 @@ role="navigation" aria-label="Secondary Menu">
  • {% include "../search/search_icon.html" %}
  • -
  • {% include "../branded_elements/link.html" with link="#" text="EN" parent=True %}
  • +
  • {% include "language_switcher.html" %}
  • {% include "../branded_elements/link.html" with link="#" text="News" %}
  • {% include "../branded_elements/link.html" with link="#" text="Contact Us" %}
  • diff --git a/hot_osm/urls.py b/hot_osm/urls.py index da6525b..6d86880 100644 --- a/hot_osm/urls.py +++ b/hot_osm/urls.py @@ -9,6 +9,7 @@ from search import views as search_views urlpatterns = [ + path("utils/", include("utils.urls", namespace="utils")), path("django-admin/", admin.site.urls), path("admin/", include(wagtailadmin_urls)), path("documents/", include(wagtaildocs_urls)), diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html new file mode 100644 index 0000000..a29ce24 --- /dev/null +++ b/utils/templates/language_switcher.html @@ -0,0 +1,16 @@ +{% load i18n %} +
    +
    + {% csrf_token %} + + +
    +
    diff --git a/utils/urls.py b/utils/urls.py new file mode 100644 index 0000000..378cf83 --- /dev/null +++ b/utils/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from utils.views import set_language + +app_name = "utils" + +urlpatterns = [ + path("set_language/", set_language, name="set_language"), +] diff --git a/utils/views.py b/utils/views.py index 91ea44a..1f3cc91 100644 --- a/utils/views.py +++ b/utils/views.py @@ -1,3 +1,9 @@ -from django.shortcuts import render +from django.shortcuts import redirect +from django.utils import translation -# Create your views here. + +def set_language(request): + language_code = request.GET.get("language_code") + translation.activate(language_code) + request.session[translation.LANGUAGE_SESSION_KEY] = language_code + return redirect(request.META.get("HTTP_REFERER")) From fe957de10d8cf8062082de439f3c554979459046 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Sun, 10 Mar 2024 21:08:55 -0700 Subject: [PATCH 05/18] Fix: Options can toggle --- hot_osm/urls.py | 2 +- utils/templates/language_switcher.html | 11 ++++++----- utils/urls.py | 7 +++---- utils/views.py | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hot_osm/urls.py b/hot_osm/urls.py index 6d86880..c82c58a 100644 --- a/hot_osm/urls.py +++ b/hot_osm/urls.py @@ -9,7 +9,6 @@ from search import views as search_views urlpatterns = [ - path("utils/", include("utils.urls", namespace="utils")), path("django-admin/", admin.site.urls), path("admin/", include(wagtailadmin_urls)), path("documents/", include(wagtaildocs_urls)), @@ -27,6 +26,7 @@ urlpatterns.extend( i18n_patterns( + path("utils/", include("utils.urls")), # For anything not caught by a more specific rule above, hand over to # Wagtail's page serving mechanism. This should be the last pattern in # the list: diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index a29ce24..260f52a 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -1,16 +1,17 @@ {% load i18n %} -
    +{% get_current_language as LANGUAGE_CODE %} {# returns preferred lang as a string - i.e. "en" #} +
    {% csrf_token %} - {% get_available_languages as LANGUAGES %} {# returns a list of tuples - i.e. ("en", "English") #} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} + {% if language.code == LANGUAGE_CODE %}selected{% endif %}>{{ language.name_local }} {% endfor %} -
    diff --git a/utils/urls.py b/utils/urls.py index 378cf83..31cbff0 100644 --- a/utils/urls.py +++ b/utils/urls.py @@ -1,9 +1,8 @@ from django.urls import path - -from utils.views import set_language +from django.views.i18n import set_language app_name = "utils" - urlpatterns = [ - path("set_language/", set_language, name="set_language"), + # ... your other urls + path("setlang/", set_language, name="set_language"), ] diff --git a/utils/views.py b/utils/views.py index 1f3cc91..27ebeea 100644 --- a/utils/views.py +++ b/utils/views.py @@ -1,9 +1,9 @@ -from django.shortcuts import redirect -from django.utils import translation +# from django.shortcuts import redirect +# from django.utils import translation -def set_language(request): - language_code = request.GET.get("language_code") - translation.activate(language_code) - request.session[translation.LANGUAGE_SESSION_KEY] = language_code - return redirect(request.META.get("HTTP_REFERER")) +# def set_language(request): +# language_code = request.POST.get("language_code") +# translation.activate(language_code) +# request.session["django_language"] = language_code +# return redirect(request.META.get("HTTP_REFERER")) From b206e14df381cf6ee21c797824d4370ddd70d5d0 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Sun, 10 Mar 2024 21:36:41 -0700 Subject: [PATCH 06/18] Added filter to capitalize language in switcher --- hot_osm/settings/base.py | 1 + utils/templates/language_switcher.html | 5 ++++- utils/templatetags/__init__.py | 0 utils/templatetags/util_filters.py | 8 ++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 utils/templatetags/__init__.py create mode 100644 utils/templatetags/util_filters.py diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index 0f5768d..fbeaafb 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -31,6 +31,7 @@ "home", "search", "users", + "utils", "wagtail.contrib.forms", "wagtail.contrib.redirects", "wagtail.embeds", diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index 260f52a..863a69f 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -1,4 +1,5 @@ {% load i18n %} +{% load util_filters %} {% get_current_language as LANGUAGE_CODE %} {# returns preferred lang as a string - i.e. "en" #}
    @@ -10,7 +11,9 @@ {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} + {% if language.code == LANGUAGE_CODE %}selected{% endif %}> + {{ language.name_local|title_case }} + {% endfor %}
    diff --git a/utils/templatetags/__init__.py b/utils/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/templatetags/util_filters.py b/utils/templatetags/util_filters.py new file mode 100644 index 0000000..fd39089 --- /dev/null +++ b/utils/templatetags/util_filters.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.filter +def title_case(value): + return value.title() From 31f94e43f3a267f64dc035199021311450dfa68a Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Mon, 11 Mar 2024 23:42:53 -0700 Subject: [PATCH 07/18] Hurray! Working language switch --- hot_osm/locale/en/LC_MESSAGES/django.mo | Bin 0 -> 380 bytes hot_osm/locale/en/LC_MESSAGES/django.po | 20 +++++++-------- hot_osm/locale/es/LC_MESSAGES/django.mo | Bin 0 -> 471 bytes hot_osm/locale/es/LC_MESSAGES/django.po | 24 +++++++++--------- hot_osm/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 467 bytes hot_osm/locale/fr/LC_MESSAGES/django.po | 24 +++++++++--------- hot_osm/settings/base.py | 5 +++- .../components/nav/primary_desktop_nav.html | 8 +++--- .../components/nav/secondary_desktop_nav.html | 4 +-- hot_osm/urls.py | 3 +-- utils/templates/language_switcher.html | 4 ++- utils/urls.py | 13 +++++----- 12 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 hot_osm/locale/en/LC_MESSAGES/django.mo create mode 100644 hot_osm/locale/es/LC_MESSAGES/django.mo create mode 100644 hot_osm/locale/fr/LC_MESSAGES/django.mo diff --git a/hot_osm/locale/en/LC_MESSAGES/django.mo b/hot_osm/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..71cbdf3e9d8d54be31066ec4ad8628bc2c1f2845 GIT binary patch literal 380 zcmYL@K~KUk7=|%=+R?Lz&%}d9i{c3jGZa>EvE7z2Nc2{r&Y96JZ6W$Y{CoZuJ5A(G zp7i_Dx9RhJeDu}vIq;l#&OC>nD^HugXY4QU{MmN?lNtRkR}RH%w3NnHT4Bh@vF%H^(V-=Ii1iQ$Qo9Pt!I1Rhe%oml#`f^NEGFCKEL->Rc=KoQ6a?!10%_7(V7ey8`V`;n{war z20Z3;uifk31QV^CRQ|iq#``$=;jWunRB8aLH({)F;i8zL{=V00y-I_qTIqGAN(}v% i$^}`yHKImSZ8jEzYJOK6-VWez49^vuhS0kh1f3tbb!oc* literal 0 HcmV?d00001 diff --git a/hot_osm/locale/en/LC_MESSAGES/django.po b/hot_osm/locale/en/LC_MESSAGES/django.po index 643b7a8..237c943 100644 --- a/hot_osm/locale/en/LC_MESSAGES/django.po +++ b/hot_osm/locale/en/LC_MESSAGES/django.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-17 13:37+0000\n" +"POT-Creation-Date: 2024-03-11 05:08+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,34 +16,35 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:6 + +#: hot_osm/templates/components/nav/primary_desktop_nav.html:7 msgid "Who We Are" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:7 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:8 msgid "Our Work" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:8 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:9 msgid "Our Mapping Hubs" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:9 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:10 msgid "Tools & Resources" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:10 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:11 msgid "Get Involved" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:11 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:12 msgid "Start Mapping" msgstr "" -#: hot_osm/templates/components/nav/secondary_desktop_nav.html:11 +#: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 msgid "News" msgstr "" -#: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 +#: hot_osm/templates/components/nav/secondary_desktop_nav.html:13 msgid "Contact Us" msgstr "" diff --git a/hot_osm/locale/es/LC_MESSAGES/django.mo b/hot_osm/locale/es/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..d5873894f039090a29f672ce5e905bc51409220e GIT binary patch literal 471 zcmYL@OHRWu6h+NXLK%R>n89NPLgpt1D5VIubxTA(C2gr-glSEhlG>H+AXo^CUq%YwNl>eU0_sYrN|`hOEL2yWN~LuH8~H%%OXF}CR=2%K@>!MQTzDd z$ZKllq{8ps=Ge!{S9drsM6PNunh0a1s}K5ZdbY?_wVtG*T#fWNSD6oIkGb=@MQKDq y+uF>m4{H8*wDpr3{Ezir1v_;(-m7^eE~RxwgEQh$Of|VF^REvjEm%F%miz+I5PviP literal 0 HcmV?d00001 diff --git a/hot_osm/locale/es/LC_MESSAGES/django.po b/hot_osm/locale/es/LC_MESSAGES/django.po index 643b7a8..217c21c 100644 --- a/hot_osm/locale/es/LC_MESSAGES/django.po +++ b/hot_osm/locale/es/LC_MESSAGES/django.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-17 13:37+0000\n" +"POT-Creation-Date: 2024-03-11 07:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,34 +16,35 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:6 -msgid "Who We Are" -msgstr "" #: hot_osm/templates/components/nav/primary_desktop_nav.html:7 -msgid "Our Work" -msgstr "" +msgid "Who We Are" +msgstr "Quiénes somos" #: hot_osm/templates/components/nav/primary_desktop_nav.html:8 +msgid "Our Work" +msgstr "Nuestro trabajo" + +#: hot_osm/templates/components/nav/primary_desktop_nav.html:9 msgid "Our Mapping Hubs" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:9 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:10 msgid "Tools & Resources" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:10 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:11 msgid "Get Involved" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:11 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:12 msgid "Start Mapping" msgstr "" -#: hot_osm/templates/components/nav/secondary_desktop_nav.html:11 +#: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 msgid "News" msgstr "" -#: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 +#: hot_osm/templates/components/nav/secondary_desktop_nav.html:13 msgid "Contact Us" msgstr "" diff --git a/hot_osm/locale/fr/LC_MESSAGES/django.mo b/hot_osm/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..9f6cd0ebef98342e6f50987c605b20e1810bead2 GIT binary patch literal 467 zcmYL@%}xR_6ou*hOq=@Bu#Q~Dr{&9(BO&u;EmkHZ5`2SE~hshn%$Xk@c| zO0Ubz(xLXj>nAjoi@dr+JHkmH9yv>Cl+X@?+r*E8lcyx+UMQ@iLnD+egww`{?kEf) zW)X)=9!c%<+ literal 0 HcmV?d00001 diff --git a/hot_osm/locale/fr/LC_MESSAGES/django.po b/hot_osm/locale/fr/LC_MESSAGES/django.po index f58dc9e..3b7e24e 100644 --- a/hot_osm/locale/fr/LC_MESSAGES/django.po +++ b/hot_osm/locale/fr/LC_MESSAGES/django.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-17 13:37+0000\n" +"POT-Creation-Date: 2024-03-11 07:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,34 +16,35 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:6 -msgid "Who We Are" -msgstr "" #: hot_osm/templates/components/nav/primary_desktop_nav.html:7 -msgid "Our Work" -msgstr "" +msgid "Who We Are" +msgstr "Qui nous sommes" #: hot_osm/templates/components/nav/primary_desktop_nav.html:8 +msgid "Our Work" +msgstr "Nos travaux" + +#: hot_osm/templates/components/nav/primary_desktop_nav.html:9 msgid "Our Mapping Hubs" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:9 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:10 msgid "Tools & Resources" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:10 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:11 msgid "Get Involved" msgstr "" -#: hot_osm/templates/components/nav/primary_desktop_nav.html:11 +#: hot_osm/templates/components/nav/primary_desktop_nav.html:12 msgid "Start Mapping" msgstr "" -#: hot_osm/templates/components/nav/secondary_desktop_nav.html:11 +#: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 msgid "News" msgstr "" -#: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 +#: hot_osm/templates/components/nav/secondary_desktop_nav.html:13 msgid "Contact Us" msgstr "" diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index 0eb2473..9ead378 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -58,13 +58,13 @@ MIDDLEWARE = [ "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.locale.LocaleMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.security.SecurityMiddleware", - "django.middleware.locale.LocaleMiddleware", "wagtail.contrib.redirects.middleware.RedirectMiddleware", ] @@ -134,12 +134,15 @@ USE_I18N = True +USE_L10N = True + WAGTAIL_I18N_ENABLED = True USE_TZ = True LOCALE_PATHS = [ os.path.join(BASE_DIR, "locale"), + os.path.join(BASE_DIR, "hot_osm", "locale"), ] WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [ diff --git a/hot_osm/templates/components/nav/primary_desktop_nav.html b/hot_osm/templates/components/nav/primary_desktop_nav.html index e0e531b..5db7aef 100644 --- a/hot_osm/templates/components/nav/primary_desktop_nav.html +++ b/hot_osm/templates/components/nav/primary_desktop_nav.html @@ -12,11 +12,9 @@
  • {% include "../branded_elements/link.html" with link="#" text=who_we_are classes="py-2" parent=True %}
  • {% include "../branded_elements/link.html" with link="#" text=our_work classes="py-2" parent=True %}
  • {% include "../branded_elements/link.html" with link="#" text=our_mapping_hubs classes="py-2" parent=True %}
  • -
  • - {% include "../branded_elements/link.html" with link="#" text="Tools & Resources" classes="py-2" parent=True %} -
  • -
  • {% include "../branded_elements/link.html" with link="#" text="Get Involved" classes="py-2" parent=True %}
  • -
  • {% include "../branded_elements/button.html" with text="Start Mapping" %}
  • +
  • {% include "../branded_elements/link.html" with link="#" text=tools_resources classes="py-2" parent=True %}
  • + {% include "../branded_elements/link.html" with link="#" text=get_involved classes="py-2" parent=True %} +
  • {% include "../branded_elements/button.html" with text=start_mapping %}
  • diff --git a/hot_osm/templates/components/nav/secondary_desktop_nav.html b/hot_osm/templates/components/nav/secondary_desktop_nav.html index 4c34f5a..aeb3a4e 100644 --- a/hot_osm/templates/components/nav/secondary_desktop_nav.html +++ b/hot_osm/templates/components/nav/secondary_desktop_nav.html @@ -12,8 +12,8 @@ {% translate "Contact Us" as contact_us %}
  • {% include "../search/search_icon.html" %}
  • {% include "language_switcher.html" %}
  • -
  • {% include "../branded_elements/link.html" with link="#" text="News" %}
  • -
  • {% include "../branded_elements/link.html" with link="#" text="Contact Us" %}
  • +
  • {% include "../branded_elements/link.html" with link="#" text=news %}
  • +
  • {% include "../branded_elements/link.html" with link="#" text=contact_us %}
  • diff --git a/hot_osm/urls.py b/hot_osm/urls.py index c82c58a..a87c54c 100644 --- a/hot_osm/urls.py +++ b/hot_osm/urls.py @@ -9,6 +9,7 @@ from search import views as search_views urlpatterns = [ + path("i18n/", include("django.conf.urls.i18n")), path("django-admin/", admin.site.urls), path("admin/", include(wagtailadmin_urls)), path("documents/", include(wagtaildocs_urls)), @@ -26,7 +27,6 @@ urlpatterns.extend( i18n_patterns( - path("utils/", include("utils.urls")), # For anything not caught by a more specific rule above, hand over to # Wagtail's page serving mechanism. This should be the last pattern in # the list: @@ -35,6 +35,5 @@ # Alternatively, if you want Wagtail pages to be served from a subpath # of your site, rather than the site root: # path("pages/", include(wagtail_urls)), - prefix_default_language=False, ) ) diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index 863a69f..dba677e 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -2,8 +2,10 @@ {% load util_filters %} {% get_current_language as LANGUAGE_CODE %} {# returns preferred lang as a string - i.e. "en" #}
    -
    + {{ request.language_code }} + {% csrf_token %} + +
    From 150f595cd5c19186f745de94d35d9a80d5f54bcc Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Tue, 12 Mar 2024 18:22:51 -0700 Subject: [PATCH 10/18] Removed unused load static --- utils/templates/language_switcher.html | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index fdfacfa..3618962 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -1,5 +1,4 @@ {% load i18n %} -{% load static %} {% load util_filters %} {% get_current_language as LANGUAGE_CODE %} {# returns preferred lang as a string - i.e. "en" #}
    From 14eba8b14829beea52c38234b84d72d3fcc0d204 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Wed, 13 Mar 2024 02:17:07 -0700 Subject: [PATCH 11/18] Switched svg to custom in select --- hot_osm/static/css/hot_osm.css | 17 +++++++++++++++++ utils/templates/language_switcher.html | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hot_osm/static/css/hot_osm.css b/hot_osm/static/css/hot_osm.css index 52556fc..2336349 100644 --- a/hot_osm/static/css/hot_osm.css +++ b/hot_osm/static/css/hot_osm.css @@ -28,3 +28,20 @@ --font-size-base-18: 1.125rem; /* 18pt */ --font-size-base-16: 1rem; /* 16pt */ } + +.language_select { + -moz-appearance: none; + -webkit-appearance: none; + appearance: none; + background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2715px%27%20height%3D%2715px%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27%23000000%27%20class%3D%27ml-0.5%27%3E%3Cpath%20d%3D%27M5.70711%209.71069C5.31658%2010.1012%205.31658%2010.7344%205.70711%2011.1249L10.5993%2016.0123C11.3805%2016.7927%2012.6463%2016.7924%2013.4271%2016.0117L18.3174%2011.1213C18.708%2010.7308%2018.708%2010.0976%2018.3174%209.70708C17.9269%209.31655%2017.2937%209.31655%2016.9032%209.70708L12.7176%2013.8927C12.3271%2014.2833%2011.6939%2014.2832%2011.3034%2013.8927L7.12132%209.71069C6.7308%209.32016%206.09763%209.32016%205.70711%209.71069Z%27%2F%3E%3C%2Fsvg%3E'); + background-repeat: no-repeat; + background-size: 15px 15px; /* Adjust the size here */ + /* background-position: calc(100% - 0.5rem) center; */ + padding-right: 22px; + padding-left: 12px; + +} + /* For IE (thanks to @SaiManoj) */ + .language_select::-ms-expand { + display: none; + } diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index 3618962..04cde5c 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -8,8 +8,8 @@ + arial-labelledby="language-select-label" + class="language-select w-full border-none"> {% get_available_languages as LANGUAGES %} {# returns a list of tuples - i.e. ("en", "English") #} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} From c384bd58871dcc58a2ed140fb2f3a1555fec16e0 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Thu, 14 Mar 2024 01:08:33 -0700 Subject: [PATCH 13/18] Language switcher is responsive on mobile --- hot_osm/templates/components/mobile/mobile_navigation.html | 6 +++--- utils/templates/language_switcher.html | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hot_osm/templates/components/mobile/mobile_navigation.html b/hot_osm/templates/components/mobile/mobile_navigation.html index 573f7cb..1d561f9 100644 --- a/hot_osm/templates/components/mobile/mobile_navigation.html +++ b/hot_osm/templates/components/mobile/mobile_navigation.html @@ -15,9 +15,9 @@
    diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index b722cc2..a90278d 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -9,7 +9,7 @@ x-model="language" @change="$event.target.form.submit()" arial-labelledby="language-select-label" - class="language-select w-full border-none"> + class="language-select border-none pl-4 lg:pl-0"> {% get_available_languages as LANGUAGES %} {# returns a list of tuples - i.e. ("en", "English") #} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} @@ -19,6 +19,5 @@ {% endfor %} - From ca01d542f57392b4fdf23c55ea88e0dd7483092b Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Thu, 14 Mar 2024 02:21:19 -0700 Subject: [PATCH 14/18] Streamlined language switcher UI with other nav links --- hot_osm/locale/en/LC_MESSAGES/django.po | 10 +++++++- hot_osm/locale/es/LC_MESSAGES/django.po | 10 +++++++- hot_osm/locale/fr/LC_MESSAGES/django.po | 10 +++++++- hot_osm/static/css/hot_osm.css | 11 ++++++--- .../components/mobile/mobile_navigation.html | 24 +++++++++++++------ utils/templates/language_switcher.html | 2 +- 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/hot_osm/locale/en/LC_MESSAGES/django.po b/hot_osm/locale/en/LC_MESSAGES/django.po index 237c943..ab7f8f5 100644 --- a/hot_osm/locale/en/LC_MESSAGES/django.po +++ b/hot_osm/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-11 05:08+0000\n" +"POT-Creation-Date: 2024-03-14 08:59+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,34 +17,42 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: hot_osm/templates/components/mobile/mobile_navigation.html:11 #: hot_osm/templates/components/nav/primary_desktop_nav.html:7 msgid "Who We Are" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:12 #: hot_osm/templates/components/nav/primary_desktop_nav.html:8 msgid "Our Work" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:13 #: hot_osm/templates/components/nav/primary_desktop_nav.html:9 msgid "Our Mapping Hubs" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:14 #: hot_osm/templates/components/nav/primary_desktop_nav.html:10 msgid "Tools & Resources" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:15 #: hot_osm/templates/components/nav/primary_desktop_nav.html:11 msgid "Get Involved" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:16 #: hot_osm/templates/components/nav/primary_desktop_nav.html:12 msgid "Start Mapping" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:17 #: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 msgid "News" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:18 #: hot_osm/templates/components/nav/secondary_desktop_nav.html:13 msgid "Contact Us" msgstr "" diff --git a/hot_osm/locale/es/LC_MESSAGES/django.po b/hot_osm/locale/es/LC_MESSAGES/django.po index 217c21c..abf1c64 100644 --- a/hot_osm/locale/es/LC_MESSAGES/django.po +++ b/hot_osm/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-11 07:40+0000\n" +"POT-Creation-Date: 2024-03-14 08:59+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,34 +17,42 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: hot_osm/templates/components/mobile/mobile_navigation.html:11 #: hot_osm/templates/components/nav/primary_desktop_nav.html:7 msgid "Who We Are" msgstr "Quiénes somos" +#: hot_osm/templates/components/mobile/mobile_navigation.html:12 #: hot_osm/templates/components/nav/primary_desktop_nav.html:8 msgid "Our Work" msgstr "Nuestro trabajo" +#: hot_osm/templates/components/mobile/mobile_navigation.html:13 #: hot_osm/templates/components/nav/primary_desktop_nav.html:9 msgid "Our Mapping Hubs" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:14 #: hot_osm/templates/components/nav/primary_desktop_nav.html:10 msgid "Tools & Resources" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:15 #: hot_osm/templates/components/nav/primary_desktop_nav.html:11 msgid "Get Involved" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:16 #: hot_osm/templates/components/nav/primary_desktop_nav.html:12 msgid "Start Mapping" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:17 #: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 msgid "News" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:18 #: hot_osm/templates/components/nav/secondary_desktop_nav.html:13 msgid "Contact Us" msgstr "" diff --git a/hot_osm/locale/fr/LC_MESSAGES/django.po b/hot_osm/locale/fr/LC_MESSAGES/django.po index 3b7e24e..8bbb1e9 100644 --- a/hot_osm/locale/fr/LC_MESSAGES/django.po +++ b/hot_osm/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-11 07:40+0000\n" +"POT-Creation-Date: 2024-03-14 08:59+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,34 +17,42 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#: hot_osm/templates/components/mobile/mobile_navigation.html:11 #: hot_osm/templates/components/nav/primary_desktop_nav.html:7 msgid "Who We Are" msgstr "Qui nous sommes" +#: hot_osm/templates/components/mobile/mobile_navigation.html:12 #: hot_osm/templates/components/nav/primary_desktop_nav.html:8 msgid "Our Work" msgstr "Nos travaux" +#: hot_osm/templates/components/mobile/mobile_navigation.html:13 #: hot_osm/templates/components/nav/primary_desktop_nav.html:9 msgid "Our Mapping Hubs" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:14 #: hot_osm/templates/components/nav/primary_desktop_nav.html:10 msgid "Tools & Resources" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:15 #: hot_osm/templates/components/nav/primary_desktop_nav.html:11 msgid "Get Involved" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:16 #: hot_osm/templates/components/nav/primary_desktop_nav.html:12 msgid "Start Mapping" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:17 #: hot_osm/templates/components/nav/secondary_desktop_nav.html:12 msgid "News" msgstr "" +#: hot_osm/templates/components/mobile/mobile_navigation.html:18 #: hot_osm/templates/components/nav/secondary_desktop_nav.html:13 msgid "Contact Us" msgstr "" diff --git a/hot_osm/static/css/hot_osm.css b/hot_osm/static/css/hot_osm.css index 569e482..bd7dfda 100644 --- a/hot_osm/static/css/hot_osm.css +++ b/hot_osm/static/css/hot_osm.css @@ -40,6 +40,11 @@ padding-right: 27.25px; } /* For IE (thanks to @SaiManoj) */ - .language-select::-ms-expand { - display: none; - } +.language-select::-ms-expand { + display: none; +} + +.language-select:focus { + outline: none !important; + box-shadow: none !important; +} diff --git a/hot_osm/templates/components/mobile/mobile_navigation.html b/hot_osm/templates/components/mobile/mobile_navigation.html index 1d561f9..3514d51 100644 --- a/hot_osm/templates/components/mobile/mobile_navigation.html +++ b/hot_osm/templates/components/mobile/mobile_navigation.html @@ -1,3 +1,4 @@ +{% load i18n %}
      -
    • {% include "../mobile/mobile_menu_link.html" with link="#" text="Who We Are" selected=True parent=True %}
    • -
    • {% include "../mobile/mobile_menu_link.html" with link="#" text="Our Work" parent=True %}
    • + {% comment %} Strings for translation {% endcomment %} + {% translate "Who We Are" as who_we_are %} + {% translate "Our Work" as our_work %} + {% translate "Our Mapping Hubs" as our_mapping_hubs %} + {% translate "Tools & Resources" as tools_resources %} + {% translate "Get Involved" as get_involved %} + {% translate "Start Mapping" as start_mapping %} + {% translate "News" as news %} + {% translate "Contact Us" as contact_us %} +
    • {% include "../mobile/mobile_menu_link.html" with link="#" text=who_we_are selected=True parent=True %}
    • +
    • {% include "../mobile/mobile_menu_link.html" with link="#" text=our_work parent=True %}
    • {% include "../mobile/mobile_menu_link.html" with link="#" text="Open Mapping Hubs" parent=True %}
    • -
    • {% include "../mobile/mobile_menu_link.html" with link="#" text="Tools & Resources" parent=True %}
    • -
    • {% include "../mobile/mobile_menu_link.html" with link="#" text="Get Involved" parent=True %}
    • -
    • {% include "../branded_elements/button.html" with text="Start Mapping" classes="my-2 ml-3 mr-4" %}
    • +
    • {% include "../mobile/mobile_menu_link.html" with link="#" text=tools_resources parent=True %}
    • +
    • {% include "../mobile/mobile_menu_link.html" with link="#" text=get_involved parent=True %}
    • +
    • {% include "../branded_elements/button.html" with text=start_mapping classes="my-2 ml-3 mr-4" %}
    diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index a90278d..5d3652b 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -9,7 +9,7 @@ x-model="language" @change="$event.target.form.submit()" arial-labelledby="language-select-label" - class="language-select border-none pl-4 lg:pl-0"> + class="language-select hover:underline border-none appearance-none focus:outline-none pl-4 cursor-pointer lg:pl-0"> {% get_available_languages as LANGUAGES %} {# returns a list of tuples - i.e. ("en", "English") #} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} From 75733e00d37713f57902d62ce88c7f0337c03329 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Thu, 14 Mar 2024 02:28:41 -0700 Subject: [PATCH 15/18] Removed unecessary link style element --- .../components/branded_elements/link.html | 14 +++++++++++++- .../components/branded_elements/link_style.html | 13 ------------- 2 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 hot_osm/templates/components/branded_elements/link_style.html diff --git a/hot_osm/templates/components/branded_elements/link.html b/hot_osm/templates/components/branded_elements/link.html index 371c566..70127c6 100644 --- a/hot_osm/templates/components/branded_elements/link.html +++ b/hot_osm/templates/components/branded_elements/link.html @@ -1,5 +1,17 @@ - {% include "../branded_elements/link_style.html" with text=text parent=parent %} + + {{ text }} + {% if parent|default:False %} + + + + {% endif %} + diff --git a/hot_osm/templates/components/branded_elements/link_style.html b/hot_osm/templates/components/branded_elements/link_style.html deleted file mode 100644 index 8d1769b..0000000 --- a/hot_osm/templates/components/branded_elements/link_style.html +++ /dev/null @@ -1,13 +0,0 @@ - - {{ text }} - {% if parent|default:False %} - - - - {% endif %} - From a460bc07e6c77f6a7db1f2ca6e39ca955f96e283 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Thu, 14 Mar 2024 02:42:29 -0700 Subject: [PATCH 16/18] Removed glitchy make command --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 0cdcd82..f08c746 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,6 @@ build-prod: @docker compose -f docker-compose.prod.yml build @docker compose -f docker-compose.prod.yml up -d -build-frontend: - @docker compose -f docker-compose.dev.yml run --rm web npm run build - test: @docker compose -f docker-compose.dev.yml run --rm web pytest From 7fe30d005af21a3a9fc097848981cf3e4e67c2e4 Mon Sep 17 00:00:00 2001 From: Kat Olaguer Date: Thu, 14 Mar 2024 02:58:30 -0700 Subject: [PATCH 17/18] Added comments for language switcher documentation --- hot_osm/static/css/hot_osm.css | 21 ++++++++++++--------- utils/templates/language_switcher.html | 6 ++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hot_osm/static/css/hot_osm.css b/hot_osm/static/css/hot_osm.css index bd7dfda..56ad2fd 100644 --- a/hot_osm/static/css/hot_osm.css +++ b/hot_osm/static/css/hot_osm.css @@ -29,21 +29,24 @@ --font-size-base-16: 1rem; /* 16pt */ } +/* Custom styling for the language select element */ .language-select { - -moz-appearance: none; - -webkit-appearance: none; - appearance: none; - background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' id='globe'%3E%3Crect width='16' height='16' fill='none'%3E%3C/rect%3E%3Ccircle cx='128' cy='128' r='96' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8'%3E%3C/circle%3E%3Cline x1='37.467' x2='218.532' y1='96' y2='96' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8'%3E%3C/line%3E%3Cline x1='37.471' x2='218.534' y1='160' y2='160' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8'%3E%3C/line%3E%3Cellipse cx='128' cy='128' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8' rx='40' ry='93.423'%3E%3C/ellipse%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-size: 18px 18px; /* Adjust the size here */ - /* background-position: calc(100% - 0.5rem) center; */ - padding-right: 27.25px; + -moz-appearance: none; /* Removes Firefox's default select styling */ + -webkit-appearance: none; /* Removes Chrome's default select styling */ + appearance: none; /* Removes the default select styling for other browsers */ + /* Custom Globe SVG: */ + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' id='globe'%3E%3Crect width='16' height='16' fill='none'%3E%3C/rect%3E%3Ccircle cx='128' cy='128' r='96' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8'%3E%3C/circle%3E%3Cline x1='37.467' x2='218.532' y1='96' y2='96' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8'%3E%3C/line%3E%3Cline x1='37.471' x2='218.534' y1='160' y2='160' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8'%3E%3C/line%3E%3Cellipse cx='128' cy='128' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='8' rx='40' ry='93.423'%3E%3C/ellipse%3E%3C/svg%3E"); + background-repeat: no-repeat; /* Ensures the SVG only appears once */ + background-size: 18px 18px; /* Controls the size of the SVG */ + padding-right: 27.25px; /* Adds space on the right side of the select element to prevent SVG overlap with the text */ } - /* For IE (thanks to @SaiManoj) */ + +/* Removes IE's default dropdown arrow */ .language-select::-ms-expand { display: none; } +/* Removes the default focus outline and box-shadow */ .language-select:focus { outline: none !important; box-shadow: none !important; diff --git a/utils/templates/language_switcher.html b/utils/templates/language_switcher.html index 5d3652b..16a770f 100644 --- a/utils/templates/language_switcher.html +++ b/utils/templates/language_switcher.html @@ -1,18 +1,20 @@ {% load i18n %} {% load util_filters %} -{% get_current_language as LANGUAGE_CODE %} {# returns preferred lang as a string - i.e. "en" #} +{% get_current_language as LANGUAGE_CODE %} {# Fetches the current language code, e.g., "en" #}
    {% csrf_token %} +