From 4e83f0221783aea1404e141e03268f9c7ab39fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Luiz=20Lorencetti?= Date: Wed, 16 Nov 2016 14:24:41 -0200 Subject: [PATCH] Partial internationalization, fix #6; Adds translation strings for pt-br --- .gitignore | 1 + locale/pt_BR/LC_MESSAGES/django.po | 95 +++++++ pets/api/tests/test_home_view.py | 9 +- pets/functional_tests/tests.py | 27 +- .../meupet/locale/pt_BR/LC_MESSAGES/django.po | 231 ++++++++++++++++++ pets/meupet/models.py | 25 +- pets/meupet/templates/meupet/_pet_form.html | 29 ++- pets/meupet/templates/meupet/_sidemenu.html | 5 +- pets/meupet/templates/meupet/edit.html | 3 +- pets/meupet/templates/meupet/index.html | 3 +- pets/meupet/templates/meupet/pet_detail.html | 42 ++-- pets/meupet/templates/meupet/poster.html | 17 +- .../meupet/templates/meupet/register_pet.html | 3 +- pets/meupet/templates/meupet/registered.html | 4 +- pets/meupet/templates/meupet/search.html | 22 +- pets/meupet/tests/test_template_tags.py | 4 +- pets/meupet/tests/test_view_pet_detail.py | 2 +- pets/meupet/tests/test_view_upload_image.py | 4 +- pets/meupet/tests/tests.py | 10 +- pets/meupet/views.py | 10 +- pets/pets/settings/prod.py | 9 +- pets/templates/_layouts/base.html | 35 +-- pets/templates/_partials/pets_list.html | 11 +- pets/users/forms.py | 16 +- pets/users/locale/pt_BR/LC_MESSAGES/django.po | 73 ++++++ pets/users/templates/users/edit_profile.html | 4 +- .../tests/test_form_user_password_recovery.py | 2 +- .../tests/test_form_user_password_reset.py | 2 +- pets/users/tests/tests.py | 11 +- pets/users/views.py | 12 +- 30 files changed, 568 insertions(+), 153 deletions(-) create mode 100644 locale/pt_BR/LC_MESSAGES/django.po create mode 100644 pets/meupet/locale/pt_BR/LC_MESSAGES/django.po create mode 100644 pets/users/locale/pt_BR/LC_MESSAGES/django.po diff --git a/.gitignore b/.gitignore index aebe67c..5cf57d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.log *.pyc *.sqlite3 +*.mo .coverage .env .idea diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po new file mode 100644 index 0000000..1fb83ae --- /dev/null +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -0,0 +1,95 @@ +# 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: 2016-11-16 22:36-0200\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" + +#: pets/templates/_layouts/base.html:8 +msgid "Missing and for adoption pets" +msgstr "Pets desaparecidos e para adoção" + +#: pets/templates/_layouts/base.html:36 +msgid "Toggle navigation" +msgstr "Alternar navegação" + +#: pets/templates/_layouts/base.html:47 +msgid "Pets" +msgstr "Pets" + +#: pets/templates/_layouts/base.html:48 +msgid "Register Pet" +msgstr "Cadastrar Pet" + +#: pets/templates/_layouts/base.html:50 +msgid "Profile" +msgstr "Perfil" + +#: pets/templates/_layouts/base.html:51 +msgid "Logout" +msgstr "Logout" + +#: pets/templates/_layouts/base.html:53 +msgid "Create Account" +msgstr "Criar Conta" + +#: pets/templates/_layouts/base.html:54 +msgid "Login" +msgstr "Login" + +#: pets/templates/_layouts/base.html:56 +msgid "About" +msgstr "Sobre" + +#: pets/templates/_layouts/base.html:57 +msgid "Search" +msgstr "Pesquisar" + +#: pets/templates/_layouts/base.html:108 +msgid "Made with ♥ in Araras, São Paulo" +msgstr "Feito com ♥ em Araras, São Paulo" + +#: pets/templates/_layouts/base.html:118 +msgid "What is it?" +msgstr "O que é?" + +#: pets/templates/_layouts/base.html:120 +msgid "" +"The purpose of Cadê meu Bicho is to provide the encounter between the best " +"or future best friends. :)" +msgstr "" +"O objetivo do Cadê meu Bicho é proporcionar o encontro entre os melhores ou " +"futuro melhores amigos. :)" + +#: pets/templates/_layouts/base.html:123 +msgid "Contact" +msgstr "Contato" + +#: pets/templates/_partials/pets_list.html:23 +msgid "Details" +msgstr "Detalhes" + +#: pets/templates/_partials/pets_list.html:35 +msgid "Previous" +msgstr "Anterior" + +#: pets/templates/_partials/pets_list.html:47 +msgid "Next" +msgstr "Próxima" + +#: pets/templates/_partials/pets_list.html:56 +msgid "No friends in this category yet :)" +msgstr "Nenhum amiguinho nessa categoria ainda. :)" diff --git a/pets/api/tests/test_home_view.py b/pets/api/tests/test_home_view.py index 7d25511..bdf2809 100644 --- a/pets/api/tests/test_home_view.py +++ b/pets/api/tests/test_home_view.py @@ -2,12 +2,12 @@ from django.shortcuts import resolve_url from django.test import TestCase + from meupet.models import City, Kind, Pet from users.models import OwnerProfile class TestGetHome(TestCase): - def setUp(self): City.objects.create(city='Araras') @@ -57,13 +57,12 @@ def test_contents(self): self.assertEqual('Costelinha', pet['description']) self.assertEqual('Araras', pet['city']) self.assertEqual('Gato', pet['kind']) - self.assertEqual('Para Adoção', pet['status']) - self.assertEqual('Pequeno', pet['size']) - self.assertEqual('Macho', pet['sex']) + self.assertEqual('For Adoption', pet['status']) + self.assertEqual('Small', pet['size']) + self.assertEqual('Male', pet['sex']) class TestPostHome(TestCase): - def setUp(self): super().setUp() self.resp = self.client.post(resolve_url('api:home')) diff --git a/pets/functional_tests/tests.py b/pets/functional_tests/tests.py index 9bd998c..4d946ee 100644 --- a/pets/functional_tests/tests.py +++ b/pets/functional_tests/tests.py @@ -83,9 +83,10 @@ def login(self): password.send_keys('admin') submit = self.browser.find_element_by_name('login') submit.click() - self.assertIn('Cadastrar Pet', self.browser.page_source) + self.assertIn('Register Pet', self.browser.page_source) - def create_pet(self): + @staticmethod + def create_pet(): admin = OwnerProfile.objects.first() kind = Kind.objects.first() pet = Pet(owner=admin, name='Costela', description='Costelinha', kind_id=kind.id, @@ -95,11 +96,11 @@ def create_pet(self): def test_login(self): self.login() - self.assertIn('Cadastrar Pet', self.browser.page_source) + self.assertIn('Register Pet', self.browser.page_source) def test_register_pet(self): self.login() - self.assertIn('Cadastrar Pet', self.browser.page_source) + self.assertIn('Register Pet', self.browser.page_source) self.browser.get(self.live_server_url + '/pets/novo/') @@ -132,7 +133,7 @@ def test_logout(self): def test_edit_own_pet(self): # user log in self.login() - self.assertIn('Cadastrar Pet', self.browser.page_source) + self.assertIn('Register Pet', self.browser.page_source) # user register a lost cat with wrong name self.browser.get(self.live_server_url + '/pets/novo/') @@ -160,11 +161,11 @@ def test_edit_own_pet(self): # assert pet was registered self.browser.find_element_by_link_text('aqui').click() - self.assertIn('Wrong Boots - Desaparecido', self.browser.page_source) + self.assertIn('Wrong Boots - Missing', self.browser.page_source) # user is redirected for the page of his pet and see the wrong name # then click on 'Edit' and get redirected for the editing page - self.browser.find_element_by_link_text('Editar').click() + self.browser.find_element_by_link_text('Edit').click() # user change the status to 'For Adoption' self.select_dropdown('status', 1) @@ -175,14 +176,14 @@ def test_edit_own_pet(self): self.browser.find_element_by_name('submit').click() # user see that he is back at the pet page - self.browser.find_element_by_link_text('Editar') + self.browser.find_element_by_link_text('Edit') # user see the correct name of the cat self.assertIn('Fuzzy Boots', self.browser.page_source) - self.assertIn('Grande', self.browser.page_source) - self.assertIn('Fêmea', self.browser.page_source) + self.assertIn('Large', self.browser.page_source) + self.assertIn('Female', self.browser.page_source) self.assertIn('Araras', self.browser.page_source) - self.assertIn('Fuzzy Boots - Para Adoção', self.browser.page_source) + self.assertIn('Fuzzy Boots - For Adoption', self.browser.page_source) def test_edit_profile_information(self): # user login @@ -205,7 +206,7 @@ def test_edit_profile_information(self): self.browser.find_element_by_name('submit').click() # user is back to the profile page and see the correct information - self.assertIn('Alterações gravadas com sucesso.', self.browser.page_source) + self.assertIn('Changes saved successfully.', self.browser.page_source) def test_upload_second_photo(self): # pre register pet @@ -229,7 +230,7 @@ def test_upload_second_photo(self): img_after = len(self.browser.find_elements_by_tag_name('img')) # verify new photo is showing - self.assertIn('Outras fotos', self.browser.page_source) + self.assertIn('More photos', self.browser.page_source) self.assertEquals(img_after, img_before + 1) def test_create_new_city(self): diff --git a/pets/meupet/locale/pt_BR/LC_MESSAGES/django.po b/pets/meupet/locale/pt_BR/LC_MESSAGES/django.po new file mode 100644 index 0000000..af2b432 --- /dev/null +++ b/pets/meupet/locale/pt_BR/LC_MESSAGES/django.po @@ -0,0 +1,231 @@ +# 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: 2016-11-16 22:36-0200\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" + +#: pets/meupet/models.py:70 +msgid "Female" +msgstr "Fêmea" + +#: pets/meupet/models.py:71 +msgid "Male" +msgstr "Macho" + +#: pets/meupet/models.py:77 +msgid "Small" +msgstr "Pequeno" + +#: pets/meupet/models.py:78 +msgid "Medium" +msgstr "Médio" + +#: pets/meupet/models.py:79 +msgid "Large" +msgstr "Grande" + +#: pets/meupet/models.py:86 +msgid "Missing" +msgstr "Desaparecido" + +#: pets/meupet/models.py:87 pets/meupet/templates/meupet/_sidemenu.html:12 +#: pets/meupet/views.py:84 +msgid "For Adoption" +msgstr "Para Adoção" + +#: pets/meupet/models.py:88 +msgid "Adopted" +msgstr "Adotado" + +#: pets/meupet/models.py:89 +msgid "Found" +msgstr "Encontrado" + +#: pets/meupet/models.py:106 pets/meupet/templates/meupet/pet_detail.html:65 +msgid "Maximum image size is 8MB" +msgstr "Tamanho máximo da imagem é 8MB" + +#: pets/meupet/templates/meupet/_pet_form.html:7 +#: pets/meupet/templates/meupet/search.html:28 +msgid "Status" +msgstr "Situação" + +#: pets/meupet/templates/meupet/_pet_form.html:16 +msgid "Name" +msgstr "Nome" + +#: pets/meupet/templates/meupet/_pet_form.html:25 +msgid "Photo" +msgstr "Foto" + +#: pets/meupet/templates/meupet/_pet_form.html:35 +#: pets/meupet/templates/meupet/pet_detail.html:78 +msgid "Description" +msgstr "Descrição" + +#: pets/meupet/templates/meupet/_pet_form.html:44 +#: pets/meupet/templates/meupet/pet_detail.html:83 +#: pets/meupet/templates/meupet/search.html:17 +msgid "City" +msgstr "Cidade" + +#: pets/meupet/templates/meupet/_pet_form.html:50 +msgid "Didn't find your city?" +msgstr "Não encontrou sua cidade?" + +#: pets/meupet/templates/meupet/_pet_form.html:51 +msgid "Click here" +msgstr "Clique aqui" + +#: pets/meupet/templates/meupet/_pet_form.html:62 +#: pets/meupet/templates/meupet/search.html:23 +msgid "Kind" +msgstr "Espécie" + +#: pets/meupet/templates/meupet/_pet_form.html:71 +#: pets/meupet/templates/meupet/pet_detail.html:89 +#: pets/meupet/templates/meupet/poster.html:37 +#: pets/meupet/templates/meupet/search.html:34 +msgid "Size" +msgstr "Tamanho" + +#: pets/meupet/templates/meupet/_pet_form.html:80 +#: pets/meupet/templates/meupet/pet_detail.html:96 +#: pets/meupet/templates/meupet/search.html:40 +msgid "Sex" +msgstr "Sexo" + +#: pets/meupet/templates/meupet/_pet_form.html:91 +msgid "Save Changes" +msgstr "Gravar Alterações" + +#: pets/meupet/templates/meupet/_pet_form.html:93 +#: pets/meupet/templates/meupet/register_pet.html:4 +msgid "Register Pet" +msgstr "Registrar Pet" + +#: pets/meupet/templates/meupet/_pet_form.html:101 +msgid "Pet Image" +msgstr "Imagem do Pet" + +#: pets/meupet/templates/meupet/_sidemenu.html:4 pets/meupet/views.py:75 +msgctxt "plural" +msgid "Missing" +msgstr "Desaparecidos" + +#: pets/meupet/templates/meupet/edit.html:4 +msgid "Edit Pet" +msgstr "Editar Pete" + +#: pets/meupet/templates/meupet/index.html:4 +msgid "Most recent entries" +msgstr "Cadastros mais recentes" + +#: pets/meupet/templates/meupet/pet_detail.html:30 +#: pets/meupet/templates/meupet/pet_detail.html:136 +msgid "Delete Pet" +msgstr "Apagar Pet" + +#: pets/meupet/templates/meupet/pet_detail.html:34 +msgid "Do you really want to erase this pet?" +msgstr "Você quer realmente apagar esse pet?" + +#: pets/meupet/templates/meupet/pet_detail.html:38 +msgid "Cancel" +msgstr "Cancelar" + +#: pets/meupet/templates/meupet/pet_detail.html:42 +msgid "Delete" +msgstr "Apagar" + +#: pets/meupet/templates/meupet/pet_detail.html:63 +msgid "Add Photo" +msgstr "Adicionar Foto" + +#: pets/meupet/templates/meupet/pet_detail.html:68 +msgid "Submit Image" +msgstr "Enviar Imagem" + +#: pets/meupet/templates/meupet/pet_detail.html:102 +#: pets/meupet/templates/meupet/poster.html:43 +msgid "Contact" +msgstr "Contato" + +#: pets/meupet/templates/meupet/pet_detail.html:108 +msgid "Share" +msgstr "Compartilhar" + +#: pets/meupet/templates/meupet/pet_detail.html:123 +msgid "Mark as found!" +msgstr "Marcar como encontrado!" + +#: pets/meupet/templates/meupet/pet_detail.html:125 +msgid "Mark as adopted!" +msgstr "Marcar como adotado!" + +#: pets/meupet/templates/meupet/pet_detail.html:131 +msgid "Edit" +msgstr "Editar" + +#: pets/meupet/templates/meupet/pet_detail.html:133 +msgid "Generate Poster" +msgstr "Gerar Cartaz" + +#: pets/meupet/templates/meupet/pet_detail.html:145 +msgid "More photos" +msgstr "Outras fotos" + +#: pets/meupet/templates/meupet/poster.html:10 +msgid "Print" +msgstr "Imprimir" + +#: pets/meupet/templates/meupet/poster.html:47 +msgid "Email" +msgstr "Email" + +#: pets/meupet/templates/meupet/poster.html:51 +msgid "Phone" +msgstr "Telefone" + +#: pets/meupet/templates/meupet/poster.html:57 +msgid "Visit:" +msgstr "Acesse:" + +#: pets/meupet/templates/meupet/registered.html:4 +msgid "Registered Pet" +msgstr "Pet Cadastrado" + +#: pets/meupet/templates/meupet/search.html:4 +#: pets/meupet/templates/meupet/search.html:46 +msgid "Search" +msgstr "Pesquisar" + +#: pets/meupet/templates/meupet/search.html:52 +msgid "Result" +msgstr "Resultado" + +#: pets/meupet/templates/meupet/search.html:64 +msgid "Details" +msgstr "Detalhes" + +#: pets/meupet/templates/meupet/search.html:70 +msgid "No result" +msgstr "Nenhum resultado" + +#: pets/meupet/views.py:99 +msgid "Please confirm your informations before registering a new pet." +msgstr "Por favor confirme suas informações antes de cadastrar um novo pet." diff --git a/pets/meupet/models.py b/pets/meupet/models.py index 341435c..f186d73 100644 --- a/pets/meupet/models.py +++ b/pets/meupet/models.py @@ -1,11 +1,12 @@ from django.core.urlresolvers import reverse from django.db import models from django.utils.text import slugify - -from users.models import OwnerProfile +from django.utils.translation import ugettext, ugettext_lazy as _ from autoslug import AutoSlugField +from users.models import OwnerProfile + class PetManager(models.Manager): def _filter_by_kind(self, kind): @@ -66,26 +67,26 @@ class Pet(models.Model): MALE = 'MA' FEMALE = 'FE' PET_SEX = ( - (FEMALE, 'Fêmea'), - (MALE, 'Macho',), + (FEMALE, _('Female')), + (MALE, _('Male')), ) SMALL = 'SM' MEDIUM = 'MD' LARGE = 'LG' PET_SIZE = ( - (SMALL, 'Pequeno'), - (MEDIUM, 'Médio'), - (LARGE, 'Grande'), + (SMALL, _('Small')), + (MEDIUM, _('Medium')), + (LARGE, _('Large')), ) MISSING = 'MI' FOR_ADOPTION = 'FA' ADOPTED = 'AD' FOUND = 'FO' PET_STATUS = ( - (MISSING, 'Desaparecido'), - (FOR_ADOPTION, 'Para Adoção'), - (ADOPTED, 'Adotado'), - (FOUND, 'Encontrado'), + (MISSING, _('Missing')), + (FOR_ADOPTION, _('For Adoption')), + (ADOPTED, _('Adopted')), + (FOUND, _('Found')), ) owner = models.ForeignKey(OwnerProfile) name = models.CharField(max_length=50) @@ -102,7 +103,7 @@ class Pet(models.Model): choices=PET_SEX, blank=True) profile_picture = models.ImageField(upload_to='pet_profiles', - help_text='Tamanho máximo da imagem é 8MB') + help_text=ugettext('Maximum image size is 8MB')) published = models.BooleanField(default=False) # published on facebook created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) diff --git a/pets/meupet/templates/meupet/_pet_form.html b/pets/meupet/templates/meupet/_pet_form.html index 98aa967..cc3d192 100644 --- a/pets/meupet/templates/meupet/_pet_form.html +++ b/pets/meupet/templates/meupet/_pet_form.html @@ -1,10 +1,10 @@ -{% load thumbnail %} +{% load i18n thumbnail %}
{% csrf_token %}
- +
{{ form.status }} @@ -13,7 +13,7 @@
- +
{{ form.name }} @@ -22,7 +22,7 @@
- +
{{ form.profile_picture }} @@ -32,7 +32,7 @@
- +
{{ form.description }} @@ -41,12 +41,15 @@
- +
{{ form.city }} {{ form.city.errors }} - Não encontrou sua cidade? Clique aqui + + {% trans "Didn't find your city?" %} + {% trans 'Click here' %} +
{{ form.new_city }} @@ -56,7 +59,7 @@
- +
{{ form.kind }} @@ -65,7 +68,7 @@
- +
{{ form.size }} @@ -74,7 +77,7 @@
- +
{{ form.sex }} @@ -85,9 +88,9 @@
@@ -95,6 +98,6 @@
Imagem Pet
diff --git a/pets/meupet/templates/meupet/_sidemenu.html b/pets/meupet/templates/meupet/_sidemenu.html index 599bcf4..27931cb 100644 --- a/pets/meupet/templates/meupet/_sidemenu.html +++ b/pets/meupet/templates/meupet/_sidemenu.html @@ -1,6 +1,7 @@ +{% load i18n %}
@@ -115,12 +115,12 @@

Cadê meu Bicho

-

O que é?

+

{% trans 'What is it?' %}

-

O objetivo do Cadê meu Bicho é proporcionar o encontro entre os melhores ou futuro melhores amigos. :)

+

{% trans 'The purpose of Cadê meu Bicho is to provide the encounter between the best or future best friends. :)' %}

-

Contato

+

{% trans 'Contact' %}

diff --git a/pets/templates/_partials/pets_list.html b/pets/templates/_partials/pets_list.html index 53bafcf..a90ea52 100644 --- a/pets/templates/_partials/pets_list.html +++ b/pets/templates/_partials/pets_list.html @@ -1,4 +1,5 @@ -{% load thumbnail %} +{% load i18n thumbnail %} +
{% if pets %} {% for pet in pets %} @@ -19,7 +20,7 @@

{{ pet }}

{{ pet.city|title }}

Detalhes + role="button">{% trans 'Details' %}
@@ -31,7 +32,7 @@

{{ pet }}

@@ -52,7 +53,7 @@

{{ pet }}

{% endif %} {% else %}
-

Nenhum amiguinho cadastrado nessa categoria ainda. :)

+

{% trans 'No friends in this category yet :)' %}

{% endif %}
\ No newline at end of file diff --git a/pets/users/forms.py b/pets/users/forms.py index c5b1f83..7f2ddaf 100644 --- a/pets/users/forms.py +++ b/pets/users/forms.py @@ -24,8 +24,8 @@ def __init__(self, *args, **kwargs): self.fields['last_name'].required = True self.fields['email'].required = True self.fields['facebook'].help_text = _( - 'Clique ' - 'aqui para saber como preencher esse campo.') + 'Click ' + 'here to learn how to fill this field.') self.fields['phone'].widget.attrs.update({'class': 'form-control'}) @@ -43,10 +43,10 @@ def __init__(self, *args, **kwargs): self.fields['password1'].widget.attrs.update({'class': 'form-control'}) self.fields['password2'].widget.attrs.update({'class': 'form-control'}) self.fields['facebook'].widget.attrs.update( - {'placeholder': 'Insira o endereço completo do seu perfil no Facebook.'}) + {'placeholder': _('Enter the full address of your Facebook profile.')}) - self.fields['username'].help_text = _('Obrigatório. 30 caracteres ou menos. ' - 'Somente letras, números e @/./+/-/_.') + self.fields['username'].help_text = _('Required. 30 characters or less. ' + 'Only letters, numbers e @/./+/-/_.') class Meta: model = OwnerProfile @@ -75,7 +75,7 @@ class Meta: def __init__(self, *args, **kwargs): super(UpdateUserForm, self).__init__(*args, **kwargs) - self.helper.add_input(Submit('submit', 'Gravar Alterações')) + self.helper.add_input(Submit('submit', _('Save Changes'))) def save(self, commit=True): self.instance.is_information_confirmed = True @@ -87,11 +87,11 @@ def __init__(self, *args, **kwargs): super(UsersPasswordRecoveryForm, self).__init__(*args, **kwargs) self.fields['username_or_email'].label = '' self.helper = FormHelper() - self.helper.add_input(Submit('recover', 'Recuperar minha senha')) + self.helper.add_input(Submit('recover', _('Recover password'))) class UsersPasswordResetForm(PasswordResetForm): def __init__(self, *args, **kwargs): super(UsersPasswordResetForm, self).__init__(*args, **kwargs) self.helper = FormHelper() - self.helper.add_input(Submit('recover', 'Recuperar minha senha')) + self.helper.add_input(Submit('recover', _('Recover password'))) diff --git a/pets/users/locale/pt_BR/LC_MESSAGES/django.po b/pets/users/locale/pt_BR/LC_MESSAGES/django.po new file mode 100644 index 0000000..8574613 --- /dev/null +++ b/pets/users/locale/pt_BR/LC_MESSAGES/django.po @@ -0,0 +1,73 @@ +# 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: 2016-11-16 22:36-0200\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" + +#: pets/users/forms.py:27 +msgid "" +"Click here to learn how to fill this field." +msgstr "" +"Clique aqui para saber como preencher este campo." + +#: pets/users/forms.py:33 +msgid "Password" +msgstr "Senha" + +#: pets/users/forms.py:34 +msgid "Password confirmation" +msgstr "Senha confirmada" + +#: pets/users/forms.py:46 +msgid "Enter the full address of your Facebook profile." +msgstr "Informe o endereço completo do seu perfil no Facebook." + +#: pets/users/forms.py:48 +msgid "Required. 30 characters or less. Only letters, numbers e @/./+/-/_." +msgstr "" +"Obrigatório. 30 caracteres ou menos. Somente letras, números e @/./+/-/_." + +#: pets/users/forms.py:60 +msgid "The two password fields didn't match." +msgstr "As duas senhas são diferentes." + +#: pets/users/forms.py:78 +msgid "Save Changes" +msgstr "Gravar Alterações" + +#: pets/users/forms.py:90 pets/users/forms.py:97 +msgid "Recover password" +msgstr "Recuperar senha" + +#: pets/users/templates/users/edit_profile.html:44 +msgid "Your Profile" +msgstr "Seu Perfil" + +#: pets/users/views.py:47 +#, python-brace-format +msgid "" +"Your account has been successfully created, access this " +"page and register the pet :)" +msgstr "" +"Sua conta foi criada com sucesso, acesse essa " +"página e realize o cadastro do pet :)" + +#: pets/users/views.py:71 +msgid "Changes saved successfully." +msgstr "Alterações salvas com sucesso." diff --git a/pets/users/templates/users/edit_profile.html b/pets/users/templates/users/edit_profile.html index 7d90172..e53c5e1 100644 --- a/pets/users/templates/users/edit_profile.html +++ b/pets/users/templates/users/edit_profile.html @@ -1,5 +1,5 @@ {% extends '_layouts/base.html' %} -{% load crispy_forms_tags static %} +{% load i18n crispy_forms_tags static %} {% block title %}Editar Perfil{% endblock %} @@ -41,6 +41,6 @@
-

Editando Perfil

+

{% trans 'Your Profile' %}

{% crispy form %} {% endblock %} \ No newline at end of file diff --git a/pets/users/tests/test_form_user_password_recovery.py b/pets/users/tests/test_form_user_password_recovery.py index 2bdf732..3b7fc42 100644 --- a/pets/users/tests/test_form_user_password_recovery.py +++ b/pets/users/tests/test_form_user_password_recovery.py @@ -14,4 +14,4 @@ def test_submit_button_present(self): """Submit button should be present in the helper""" form = UsersPasswordRecoveryForm() - self.assertIn('Recuperar minha senha', form.helper.inputs[0].value) + self.assertIn('Recover password', form.helper.inputs[0].value) diff --git a/pets/users/tests/test_form_user_password_reset.py b/pets/users/tests/test_form_user_password_reset.py index 7b47814..b44b117 100644 --- a/pets/users/tests/test_form_user_password_reset.py +++ b/pets/users/tests/test_form_user_password_reset.py @@ -8,4 +8,4 @@ def test_submit_button_present(self): """Submit button should be present in the helper""" form = UsersPasswordResetForm(user=None) - self.assertIn('Recuperar minha senha', form.helper.inputs[0].value) + self.assertIn('Recover password', form.helper.inputs[0].value) diff --git a/pets/users/tests/tests.py b/pets/users/tests/tests.py index 21023f7..cb9f332 100644 --- a/pets/users/tests/tests.py +++ b/pets/users/tests/tests.py @@ -12,7 +12,8 @@ def login_new_user(self): self.create_user() self.client.login(username='tester', password='test123') - def create_user(self, username='tester'): + @staticmethod + def create_user(username='tester'): user = OwnerProfile(first_name='Test First Name', last_name='Tester', email='te@ste.com', username=username, is_information_confirmed=True) user.set_password('test123') @@ -36,7 +37,7 @@ def test_authenticate_with_recent_user(self): self.client.login(username='tester', password='test123') response = self.client.get('/') - self.assertContains(response, 'Cadastrar Pet') + self.assertContains(response, 'Register Pet') def test_render_own_profile(self): """User should be shown it's own profile""" @@ -52,7 +53,7 @@ def test_show_profile_link_if_logged(self): response = self.client.get('/') - self.assertContains(response, 'Seu Perfil') + self.assertContains(response, 'Profile') def test_edit_view_show_form_for_update_profile_information(self): """Show correct page for the edit profile view""" @@ -60,8 +61,8 @@ def test_edit_view_show_form_for_update_profile_information(self): response = self.client.get(reverse('users:edit')) - self.assertContains(response, 'Gravar Alterações') - self.assertContains(response, 'Editando Perfil') + self.assertContains(response, 'Save Changes') + self.assertContains(response, 'Your Profile') self.assertTemplateUsed(response, 'users/edit_profile.html') def test_render_profile_with_correct_template(self): diff --git a/pets/users/views.py b/pets/users/views.py index 7224b4e..75d28f5 100644 --- a/pets/users/views.py +++ b/pets/users/views.py @@ -6,6 +6,7 @@ from django.template.context import RequestContext from django.utils.http import is_safe_url from django.views.generic import CreateView, TemplateView, UpdateView, DetailView +from django.utils.translation import ugettext as _ from braces.views import LoginRequiredMixin, AnonymousRequiredMixin from password_reset.views import Recover, RecoverDone, Reset, ResetDone @@ -42,8 +43,9 @@ class CreateUserView(AnonymousRequiredMixin, CreateView): form_class = RegisterForm template_name = 'users/create.html' authenticated_redirect_url = reverse_lazy('meupet:index') - msg = 'Sua conta foi criada com sucesso, acesse essa ' \ - 'página e realize o cadastro do pet :)' + + msg = _('Your account has been successfully created, access ' + 'this page and register the pet :)') def form_valid(self, form): form.instance.is_information_confirmed = True @@ -53,8 +55,8 @@ def get_success_url(self): url = reverse('meupet:register') messages.success(self.request, self.msg.format(url)) user = authenticate( - username=self.request.POST.get('username'), - password=self.request.POST.get('password1') + username=self.request.POST.get('username'), + password=self.request.POST.get('password1') ) login(self.request, user) return reverse('meupet:index') @@ -66,7 +68,7 @@ class EditUserProfileView(LoginRequiredMixin, UpdateView): form_class = UpdateUserForm def get_success_url(self): - messages.success(self.request, 'Alterações gravadas com sucesso.') + messages.success(self.request, _('Changes saved successfully.')) return reverse('meupet:index') def get_object(self, queryset=None):