diff --git a/intl_tools/__init__.py b/intl_tools/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/intl_tools/admin.py b/intl_tools/admin.py new file mode 100644 index 0000000..846f6b4 --- /dev/null +++ b/intl_tools/admin.py @@ -0,0 +1 @@ +# Register your models here. diff --git a/intl_tools/apps.py b/intl_tools/apps.py new file mode 100644 index 0000000..0e508b5 --- /dev/null +++ b/intl_tools/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class IntlToolsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'intl_tools' diff --git a/intl_tools/forms.py b/intl_tools/forms.py new file mode 100644 index 0000000..35d9fc2 --- /dev/null +++ b/intl_tools/forms.py @@ -0,0 +1,23 @@ +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Column, Layout, Row, Submit +from django import forms +from django.conf import settings +from django.utils.translation import gettext_lazy as _ + + +class LanguageForm(forms.Form): + language = forms.ChoiceField( + choices=settings.LANGUAGES, + label=_("Language"), + ) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.form_method = 'post' + self.helper.layout = Layout( + Row( + Column('language', css_class='col-md-6'), + ), + Submit('submit', _("Change Language"), css_class='btn btn-primary') + ) \ No newline at end of file diff --git a/intl_tools/migrations/__init__.py b/intl_tools/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/intl_tools/models.py b/intl_tools/models.py new file mode 100644 index 0000000..6b20219 --- /dev/null +++ b/intl_tools/models.py @@ -0,0 +1 @@ +# Create your models here. diff --git a/intl_tools/tests.py b/intl_tools/tests.py new file mode 100644 index 0000000..a39b155 --- /dev/null +++ b/intl_tools/tests.py @@ -0,0 +1 @@ +# Create your tests here. diff --git a/intl_tools/views.py b/intl_tools/views.py new file mode 100644 index 0000000..6f4e52b --- /dev/null +++ b/intl_tools/views.py @@ -0,0 +1,25 @@ +from django.conf import settings +from django.shortcuts import redirect, render +from django.utils import translation + +from .forms import LanguageForm + + +def view_change_language(request): + if request.method == 'POST': + form = LanguageForm(request.POST) + if form.is_valid(): + language = form.cleaned_data['language'] + translation.activate(language) + request.session['django_language'] = language + next_url = '/' + response = redirect(next_url) + response.set_cookie(settings.LANGUAGE_COOKIE_NAME, language) + return response + else: + form = LanguageForm(initial={'language': translation.get_language()}) + + if request.user.is_authenticated: + return render(request, 'generic_form.html', {'form': form}) + else: + return render(request, 'generic_form_guest.html', {'form': form}) \ No newline at end of file diff --git a/locale/pt_BR/LC_MESSAGES/django.mo b/locale/pt_BR/LC_MESSAGES/django.mo new file mode 100644 index 0000000..fb309f4 Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/django.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po new file mode 100644 index 0000000..8c7bbc6 --- /dev/null +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -0,0 +1,87 @@ +# 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: 2025-04-14 15:34-0300\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" + +#: intl_tools/forms.py:11 templates/accounts/login.html:36 +msgid "Language" +msgstr "Idioma" + +#: intl_tools/forms.py:22 templates/base.html:80 +msgid "Change Language" +msgstr "Alterar Idioma" + +#: templates/accounts/login.html:14 +msgid "Username" +msgstr "Usuário" + +#: templates/accounts/login.html:23 +msgid "Password" +msgstr "Senha" + +#: templates/accounts/login.html:32 +msgid "Login" +msgstr "Acessar" + +#: templates/accounts/logout.html:11 +msgid "You have been successfully logged out." +msgstr "Você foi desconectado com sucesso." + +#: templates/accounts/logout.html:14 +msgid "Login again" +msgstr "Acessar novamente" + +#: templates/base.html:112 +msgid "Status" +msgstr "Estado" + +#: templates/base.html:158 +msgid "User Manager" +msgstr "Configurar Usuários" + +#: templates/base.html:176 +msgid "VPN Invite" +msgstr "Convite para VPN" + +#: templates/base.html:254 +msgid "Update Required" +msgstr "Atualização Necessária" + +#: templates/base.html:256 +msgid "" +"Your WireGuard settings have been modified. To apply these changes, please " +"update the configuration and reload the WireGuard service." +msgstr "" +"Suas configurações do WireGuard foram modificadas. Para aplicar essas " +"mudanças, atualize a configuração e recarregue o serviço WireGuard." + +#: templates/base.html:265 +msgid "Update and restart service" +msgstr "Atualizar e reiniciar o serviço" + +#: templates/base.html:273 +msgid "Update and reload service" +msgstr "Atualizar e recarregar o serviço" + +#: templates/base.html:286 +msgid "Update Available" +msgstr "Atualização Disponível" + +#: templates/base.html:288 +msgid "Version" +msgstr "Versão" diff --git a/templates/accounts/login.html b/templates/accounts/login.html index 974a5bc..602abe1 100644 --- a/templates/accounts/login.html +++ b/templates/accounts/login.html @@ -1,62 +1,50 @@ {% extends "base_login.html" %} +{% load i18n %} {% block content %} +
+ +
+
+
+ {% csrf_token %} +
+ +
+
+ +
+
+
-
- +
- -
-
-
- {% csrf_token %} -
- -
-
- -
-
-
- -
- -
-
- -
-
-
- - - -
-
-
-
- -
-
-
- - - -
- -
-
- - - - - - - - - {% endblock %} -``` + +{% endblock %} diff --git a/templates/accounts/logout.html b/templates/accounts/logout.html index 55a5d6b..0896bc8 100644 --- a/templates/accounts/logout.html +++ b/templates/accounts/logout.html @@ -1,35 +1,20 @@ {% extends "base_login.html" %} +{% load i18n %} {% block content %} - -
- - -
-
- - - - - -
- -
- Login again +
+ +
+
+ +
-
- - -
- -
-
- - - - - - {% endblock %} -``` +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 2d1d5b7..edfadf0 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,5 +1,7 @@ - +{% load i18n %} +{% get_current_language as CURRENT_LANGUAGE %} + @@ -70,13 +72,16 @@ -