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 0000000..71cbdf3 Binary files /dev/null and b/hot_osm/locale/en/LC_MESSAGES/django.mo differ diff --git a/hot_osm/locale/en/LC_MESSAGES/django.po b/hot_osm/locale/en/LC_MESSAGES/django.po index 643b7a8..ab7f8f5 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-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 +16,43 @@ 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/mobile/mobile_navigation.html:11 +#: 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/mobile/mobile_navigation.html:12 +#: 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/mobile/mobile_navigation.html:13 +#: 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/mobile/mobile_navigation.html:14 +#: 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/mobile/mobile_navigation.html:15 +#: 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/mobile/mobile_navigation.html:16 +#: 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/mobile/mobile_navigation.html:17 +#: 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/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.mo b/hot_osm/locale/es/LC_MESSAGES/django.mo new file mode 100644 index 0000000..d587389 Binary files /dev/null and b/hot_osm/locale/es/LC_MESSAGES/django.mo differ diff --git a/hot_osm/locale/es/LC_MESSAGES/django.po b/hot_osm/locale/es/LC_MESSAGES/django.po index 643b7a8..abf1c64 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-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 +16,43 @@ 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/mobile/mobile_navigation.html:11 #: 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/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/nav/primary_desktop_nav.html:9 +#: 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/nav/primary_desktop_nav.html:10 +#: 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/nav/primary_desktop_nav.html:11 +#: 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/nav/secondary_desktop_nav.html:11 +#: 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/nav/secondary_desktop_nav.html:12 +#: 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.mo b/hot_osm/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000..9f6cd0e Binary files /dev/null and b/hot_osm/locale/fr/LC_MESSAGES/django.mo differ diff --git a/hot_osm/locale/fr/LC_MESSAGES/django.po b/hot_osm/locale/fr/LC_MESSAGES/django.po index f58dc9e..8bbb1e9 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-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 +16,43 @@ 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/mobile/mobile_navigation.html:11 #: 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/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/nav/primary_desktop_nav.html:9 +#: 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/nav/primary_desktop_nav.html:10 +#: 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/nav/primary_desktop_nav.html:11 +#: 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/nav/secondary_desktop_nav.html:11 +#: 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/nav/secondary_desktop_nav.html:12 +#: 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/settings/base.py b/hot_osm/settings/base.py index 4c88323..9ead378 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", @@ -57,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", ] @@ -74,6 +75,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": { @@ -126,21 +128,24 @@ # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ -LANGUAGE_CODE = "en-us" +LANGUAGE_CODE = "en" TIME_ZONE = "UTC" 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 = [ +WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [ ("en", "English"), ("fr", "French"), ("es", "Spanish"), diff --git a/hot_osm/static/css/hot_osm.css b/hot_osm/static/css/hot_osm.css index 52556fc..a87df9a 100644 --- a/hot_osm/static/css/hot_osm.css +++ b/hot_osm/static/css/hot_osm.css @@ -28,3 +28,26 @@ --font-size-base-18: 1.125rem; /* 18pt */ --font-size-base-16: 1rem; /* 16pt */ } + +/* Custom styling for the language select element */ +.language-select { + -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 */ +} + +/* 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/hot_osm/templates/components/mobile/mobile_navigation.html b/hot_osm/templates/components/mobile/mobile_navigation.html index 573f7cb..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/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 659e106..aeb3a4e 100644 --- a/hot_osm/templates/components/nav/secondary_desktop_nav.html +++ b/hot_osm/templates/components/nav/secondary_desktop_nav.html @@ -11,9 +11,9 @@ {% translate "News" as news %} {% translate "Contact Us" as contact_us %}
  • {% include "../search/search_icon.html" %}
  • -
  • {% include "../branded_elements/link.html" with link="#" text="EN" parent=True %}
  • -
  • {% include "../branded_elements/link.html" with link="#" text="News" %}
  • -
  • {% include "../branded_elements/link.html" with link="#" text="Contact Us" %}
  • +
  • {% 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 523c031..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)), 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/templates/language_switcher.html b/utils/templates/language_switcher.html new file mode 100644 index 0000000..16a770f --- /dev/null +++ b/utils/templates/language_switcher.html @@ -0,0 +1,25 @@ +{% load i18n %} +{% load util_filters %} +{% get_current_language as LANGUAGE_CODE %} {# Fetches the current language code, e.g., "en" #} +
    +
    + {% csrf_token %} + + + +
    +
    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() 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/urls.py b/utils/urls.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/views.py b/utils/views.py new file mode 100644 index 0000000..e69de29