Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Added italian translation for messages
Browse files Browse the repository at this point in the history
  • Loading branch information
morlandi committed Jan 2, 2021
1 parent 173dfd7 commit 01a000f
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nosetests.xml
htmlcov

# Translations
*.mo
#*.mo

# Mr Developer
.mr.developer.cfg
Expand Down
30 changes: 27 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ In your settings, add:
'frontend_forms',
]
Optionally, include library's views mapping (file `urls.py`):
Include library's views mapping (file `urls.py`):

.. code:: python
Expand All @@ -59,12 +59,24 @@ and optionally the sample HTML template:
<link rel='stylesheet' href="{% static 'frontend_forms/css/frontend_forms.css' %}">
<script src="{% static 'frontend_forms/js/frontend_forms.jsx' %}"></script>
<script src="{% url 'frontend_forms:javascript-catalog' %}"></script>
{% include 'frontend_forms/dialogs.html' %}
**OPTIONALLY**, since the js code uses the `class` keyword, you might want to transpile
`frontend_forms.jsx` for maximum compatibility, to support oldest browsers.
Please note the third row in the snippets above:
.. code:: html
<script src="{% url 'frontend_forms:javascript-catalog' %}"></script>
**Since v0.3.0 it is mandatory to include the dynamically generated
javascript catalog**, since a few messages have been translated in javascript code
following these instructions: `Django Internationalization: in JavaScript code <https://docs.djangoproject.com/en/3.1/topics/i18n/translation/#internationalization-in-javascript-code>`_.
For example, using Babel and django-compress:
.. code:: html
Expand Down Expand Up @@ -1034,7 +1046,19 @@ Follow these steps:
django-select2 support
----------------------
Requirements (in file "base.html")::
Requirements::
pip install django-select2
npm install select2
Changes to "settings.py"::
INSTALLED_APPS = [
...
'django_select2',
...
Changes to "base.html"::
<link rel="stylesheet" type="text/css" href="{% static 'select2/dist/css/select2.min.css' %}" />
Expand All @@ -1043,7 +1067,7 @@ Requirements (in file "base.html")::
<script language="javascript">
$.fn.select2.defaults.set('language', 'it');
</script>
<script src="{% static 'django_select2/django_select2.js' %}"</script>
<script src="{% static 'django_select2/django_select2.js' %}"></script>
Follow these steps:
Expand Down
1 change: 0 additions & 1 deletion example/others/templates/others/chained_selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ <h3>{% trans 'References' %}</h3>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Edit a new track ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true,
callback: function(event_name, dialog, params) {
Expand Down
11 changes: 8 additions & 3 deletions example/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGES = (
('en', u'English'),
('it', u'Italiano'),
)

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'

USE_I18N = True
# LANGUAGE_CODE = 'it'
# TIME_ZONE = 'Europe/Rome'

USE_I18N = True
USE_L10N = True

USE_TZ = True


Expand Down
5 changes: 3 additions & 2 deletions example/project/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ <h1>Content goes here</h1>
<script src="{% static 'sweetalert2/dist/sweetalert2.min.js' %}"></script>
<script src="{% static 'promise-polyfill/dist/polyfill.min.js' %}"></script>
<script src="{% static 'frontend_forms/js/frontend_forms.jsx' %}"></script>
<script src="{% url 'frontend_forms:javascript-catalog' %}"></script>
<script src="{% static 'dropzone/dist/min/dropzone.min.js' %}"></script>

{# Select2 support #}
Expand Down Expand Up @@ -102,8 +103,8 @@ <h1>Content goes here</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-sign-in"></i> Login ...',
button_save_label: "Login",
button_close_label: "Close",
button_save_label: "{% trans 'Login' %}",
button_close_label: "{% trans 'Close' %}",
callback: function(event_name, dialog, params) {
switch (event_name) {
case "submitted":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ <h3>Artists</h3>
width: '600px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Create an Artist ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true,
callback: function(event_name, dialog, params) {
Expand Down Expand Up @@ -91,7 +90,6 @@ <h3>Artists</h3>
width: '600px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Update an Artist ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true,
callback: function(event_name, dialog, params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ <h3>Artists</h3>
width: '600px',
min_height: '200px',
//title: '<i class="fa fa-calculator"></i> Create an Artist ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true,
callback: function(event_name, dialog, params) {
Expand Down
1 change: 0 additions & 1 deletion example/samples/templates/samples/form_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ <h1>Forms with advanced widgets</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Edit a new track ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true,
callback: function(event_name, dialog, params) {
Expand Down
8 changes: 2 additions & 6 deletions example/samples/templates/samples/form_submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ <h1>Simple Dialogs with Form validation</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Select an object ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true
});
Expand All @@ -82,7 +81,6 @@ <h1>Simple Dialogs with Form validation</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Select an object ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true,
callback: dialog2_callback
Expand All @@ -95,7 +93,6 @@ <h1>Simple Dialogs with Form validation</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Select an object ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true
});
Expand All @@ -107,7 +104,6 @@ <h1>Simple Dialogs with Form validation</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-calculator"></i> Select an object ...',
button_save_label: "Save",
button_save_initially_hidden: true,
enable_trace: true
});
Expand All @@ -117,8 +113,8 @@ <h1>Simple Dialogs with Form validation</h1>
width: '400px',
min_height: '200px',
title: '<i class="fa fa-sign-in"></i> Login ...',
button_save_label: "Login",
button_close_label: "Close"
button_save_label: "{% trans 'Login' %}",
button_close_label: "{% trans 'Close' %}"
});

});
Expand Down
Binary file added frontend_forms/locale/it/LC_MESSAGES/django.mo
Binary file not shown.
63 changes: 63 additions & 0 deletions frontend_forms/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-02 15:18+0100\n"
"PO-Revision-Date: 2021-01-02 16:56+0100\n"
"Language: it\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"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.4.2\n"

#: templates/frontend_forms/check_logged_in_failed_inner.html:4
msgid "This action requires authentication"
msgstr "Questa azione richiede autenticazione"

#: templates/frontend_forms/check_logged_in_failed_inner.html:5
msgid "Please login and try again"
msgstr "Si prega di inserire le corrette credenziali di accesso e riprovare"

#: templates/frontend_forms/dialogs.html:23
msgid "Close"
msgstr "Chiudi"

#: templates/frontend_forms/dialogs.html:24
msgid "Save"
msgstr "Salva"

#: templates/frontend_forms/generic_form2_inner.html:30
msgid "Send"
msgstr "Invia"

#: templates/frontend_forms/login.html:19
msgid "Login"
msgstr "Accesso"

#: templates/frontend_forms/login.html:20
msgid "Please enter your username and password below"
msgstr "Inserire qui sotto il proprio username e la password"

#: templates/frontend_forms/login_successful_message.html:2
msgid "You're now logged in"
msgstr "Hai effettuato l'accesso"

#: templates/frontend_forms/render_form.html:5
msgid "Please correct the error below."
msgstr "Si prega di correggere l’errore di seguito evidenziato."

#: templates/frontend_forms/render_form.html:7
msgid "Please correct the errors below."
msgstr "Si prega di correggere gli errori di seguito evidenziati."

#: views.py:106
msgid "Logged out"
msgstr "Disconnesso"
Binary file added frontend_forms/locale/it/LC_MESSAGES/djangojs.mo
Binary file not shown.
35 changes: 35 additions & 0 deletions frontend_forms/locale/it/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-02 17:42+0100\n"
"PO-Revision-Date: 2021-01-02 17:42+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: it\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"
"X-Generator: Poedit 2.4.2\n"

#: static/frontend_forms/js/frontend_forms.jsx:29
msgid "Save"
msgstr "Salva"

#: static/frontend_forms/js/frontend_forms.jsx:31
msgid "Cancel"
msgstr "Annulla"

#: static/frontend_forms/js/frontend_forms.jsx:363
msgid "ERROR"
msgstr "ERRORE"

#: static/frontend_forms/js/frontend_forms.jsx:368
msgid "Close"
msgstr "Chiudi"
8 changes: 4 additions & 4 deletions frontend_forms/static/frontend_forms/js/frontend_forms.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class Dialog {
height: null,
min_height: null,
max_height: null,
button_save_label: 'Save',
button_save_label: gettext('Save'),
button_save_initially_hidden: false,
button_close_label: 'Cancel',
button_close_label: gettext('Cancel'),
title: '',
footer_text: '',
enable_trace: false,
Expand Down Expand Up @@ -360,12 +360,12 @@ window.FrontendForms = (function() {
cancelButtonClass: 'btn btn-lg btn-default',
buttonsStyling: false,
reverseButtons: true,
title: 'ERROR',
title: gettext('ERROR'),
text: errorDetails,
type: 'error',
icon: 'error',
confirmButtonClass: 'btn btn-lg btn-danger',
confirmButtonText: 'Close'
confirmButtonText: gettext('Close')
});
}
// failing that, we fallback to a simple alert
Expand Down
6 changes: 3 additions & 3 deletions frontend_forms/templates/frontend_forms/dialogs.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static %}
{% load static i18n %}

{# "How To Create a Modal Box":; #}
{# https://www.w3schools.com/howto/howto_css_modals.asp #}
Expand All @@ -19,8 +19,8 @@
{% endcomment %}
</div>
<div class="dialog-footer">
<input type="submit" value="Close" class="btn btn-close" />
<input type="submit" value="Save" class="btn btn-save" />
<input type="submit" value="{% trans 'Close' %}" class="btn btn-close" />
<input type="submit" value="{% trans 'Save' %}ß" class="btn btn-save" />
<div class="text">footer</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% render_form form %}
<input type="hidden" name="object_id" value="{{ object.id|default:'' }}">
<div class="form-submit-row">
<input type="submit" value="Save" />
<input type="submit" value="{% trans 'Save' %}" />
</div>
</form>
</div>
Expand Down
5 changes: 5 additions & 0 deletions frontend_forms/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from django.urls import path
from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView
from django.views.i18n import JavaScriptCatalog
from . import views

app_name = 'frontend_forms'

urlpatterns = [

# check at "http://127.0.0.1:8000/frontend_forms/jsi18n/"
path('jsi18n/', JavaScriptCatalog.as_view(packages=['frontend_forms']), name='javascript-catalog'),

path('login/', views.login, {'template_name': 'frontend_forms/login.html', }, name="login"),
path('logout/', views.logout, {'next_page': '/'}, name="logout"),

Expand Down

0 comments on commit 01a000f

Please sign in to comment.