diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..20267b1 Binary files /dev/null and b/db.sqlite3 differ diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 0000000..ac16c57 Binary files /dev/null and b/locale/en/LC_MESSAGES/django.mo differ diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po new file mode 100644 index 0000000..12b2216 --- /dev/null +++ b/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,35 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# 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: 2023-12-09 09:16+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: multilanguage/settings.py:34 +msgid "English" +msgstr "" + +#: multilanguage/settings.py:35 +msgid "French" +msgstr "" + +#: multilanguage/settings.py:36 +msgid "Spanish" +msgstr "" + +#: web/views.py:5 +msgid "hola" +msgstr "hello" diff --git a/locale/es/LC_MESSAGES/django.mo b/locale/es/LC_MESSAGES/django.mo new file mode 100644 index 0000000..f708690 Binary files /dev/null and b/locale/es/LC_MESSAGES/django.mo differ diff --git a/locale/es/LC_MESSAGES/django.po b/locale/es/LC_MESSAGES/django.po new file mode 100644 index 0000000..382a397 --- /dev/null +++ b/locale/es/LC_MESSAGES/django.po @@ -0,0 +1,35 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# 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: 2023-12-09 09:16+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: multilanguage/settings.py:34 +msgid "English" +msgstr "" + +#: multilanguage/settings.py:35 +msgid "French" +msgstr "" + +#: multilanguage/settings.py:36 +msgid "Spanish" +msgstr "" + +#: web/views.py:5 +msgid "hola" +msgstr "hola" diff --git a/locale/fr/LC_MESSAGES/django.mo b/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000..a7f4da5 Binary files /dev/null and b/locale/fr/LC_MESSAGES/django.mo differ diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 0000000..4165544 --- /dev/null +++ b/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,35 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# 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: 2023-12-09 09:16+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: multilanguage/settings.py:34 +msgid "English" +msgstr "" + +#: multilanguage/settings.py:35 +msgid "French" +msgstr "" + +#: multilanguage/settings.py:36 +msgid "Spanish" +msgstr "" + +#: web/views.py:5 +msgid "hola" +msgstr "(hola en frances)" diff --git a/multilanguage/__pycache__/__init__.cpython-310.pyc b/multilanguage/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..a0ee9e8 Binary files /dev/null and b/multilanguage/__pycache__/__init__.cpython-310.pyc differ diff --git a/multilanguage/__pycache__/settings.cpython-310.pyc b/multilanguage/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..4447d6a Binary files /dev/null and b/multilanguage/__pycache__/settings.cpython-310.pyc differ diff --git a/multilanguage/__pycache__/urls.cpython-310.pyc b/multilanguage/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..580d464 Binary files /dev/null and b/multilanguage/__pycache__/urls.cpython-310.pyc differ diff --git a/multilanguage/__pycache__/wsgi.cpython-310.pyc b/multilanguage/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..e59340d Binary files /dev/null and b/multilanguage/__pycache__/wsgi.cpython-310.pyc differ diff --git a/multilanguage/settings.py b/multilanguage/settings.py index 2e29397..5ad0033 100644 --- a/multilanguage/settings.py +++ b/multilanguage/settings.py @@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/5.0/ref/settings/ """ from pathlib import Path - +from django.utils.translation import gettext_lazy as _ # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -30,6 +30,11 @@ ALLOWED_HOSTS = [] # Application definition +LANGUAGES = ( + ('en', _('English')), + ('fr', _('French')), + ('es', _('Spanish')), +) INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', @@ -44,6 +49,7 @@ MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', @@ -121,3 +127,6 @@ STATIC_URL = 'static/' # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +LOCALE_PATHS = [ + BASE_DIR / 'locale/', +] diff --git a/multilanguage/urls.py b/multilanguage/urls.py index bed4cef..7b1721f 100644 --- a/multilanguage/urls.py +++ b/multilanguage/urls.py @@ -16,7 +16,9 @@ Including another URLconf """ from django.contrib import admin from django.urls import path - -urlpatterns = [ +from django.conf.urls.i18n import i18n_patterns +from web.views import home +urlpatterns = i18n_patterns( path('admin/', admin.site.urls), -] + path('', home) +) diff --git a/web/__init__.py b/web/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/__pycache__/__init__.cpython-310.pyc b/web/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..272affd Binary files /dev/null and b/web/__pycache__/__init__.cpython-310.pyc differ diff --git a/web/__pycache__/views.cpython-310.pyc b/web/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..6976ab8 Binary files /dev/null and b/web/__pycache__/views.cpython-310.pyc differ diff --git a/web/admin.py b/web/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/web/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/web/apps.py b/web/apps.py new file mode 100644 index 0000000..682e923 --- /dev/null +++ b/web/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WebConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'web' diff --git a/web/migrations/__init__.py b/web/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/models.py b/web/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/web/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/web/tests.py b/web/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/web/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/web/views.py b/web/views.py new file mode 100644 index 0000000..ce2185b --- /dev/null +++ b/web/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render, HttpResponse +from django.utils.translation import gettext_lazy as _ +# Create your views here. +def home(request): + welcome = _("hola") + return HttpResponse(welcome) \ No newline at end of file