Project

General

Profile

Segnalazione #197

Internazionalizzazione Datatables

Added by Marco Marinello over 4 years ago. Updated over 4 years ago.

Status:
Chiuso
Priority:
Normale
Start date:
02/23/2017
Due date:
% Done:

100%


Description

In /users/user/list , ad esempio, vi è una tabella creata con Datatables. Questa presenta però scritte in inglese. Per una traduzione completa, vanno incluse anche quelle scritte.
Come giustamente ricordato in altri tickets, i file statici non sono influenzati dall'i18n di django. Propongo quindi questa soluzione:
1) Modificare il file statico datatables.min.js con quello allegato, che ho predisposto per essere internazionalizzato;
2) Modificare le pagine che utilizzano Datatables inserendo

<script type="text/javascript">
i18n = {
    "Showing _START_ to _END_ of _TOTAL_ entries": "{% trans 'Showing _START_ to _END_ of _TOTAL_ entries' %}",
    "(filtered from _MAX_ total entries)": "({% trans 'filtered from _MAX_ total entries' %})",
    "Show _MENU_ entries": "{% trans 'Show _MENU_ entries' %}",
    "Search:": "{% trans 'Search' %}:",
    "Previous": "{% trans 'Previous' %}",
    "Next": "{% trans 'Next' %}",
    "No matching records found": "{% trans 'No matching records found' %}",
    "Showing 0 to 0 of 0 entries": "{% trans 'Showing 0 to 0 of 0 entries' %}",
}
</script>

datatables.min.js - File internazionalizzato datatables (1.19 MB) Marco Marinello, 02/23/2017 05:49 PM

Associated revisions

Revision 5b431a2e (diff)
Added by Christopher R. Gabriel over 4 years ago

added i18n backend files for dt - close #197

History

#1 Updated by Christopher R. Gabriel over 4 years ago

Eviterei di modificare sorgenti upstream, che li rende difficili poi da aggiornare e mantenere.

La soluzione e' di usare i file di traduzione esterni, visto che datatables supporta gia' la localizzazione: https://datatables.net/plug-ins/i18n/

#2 Updated by Christopher R. Gabriel over 4 years ago

  • Status changed from Nuovo to Risolto
  • % Done changed from 0 to 100

#3 Updated by Marco Marinello over 4 years ago

Le tabelle sono state tradotte ma ora connettendomi allo / di octonet ottengo (dopo aver aggiornato all'ultima versione da master)

Environment:

Request Method: GET
Request URL: http://XXX.XXX.XXX.XXX:13402/

Django Version: 1.8.16
Python Version: 3.4.2
Installed Applications:
['django.contrib.sessions',
 'django.contrib.messages',
 'whitenoise.runserver_nostatic',
 'django.contrib.staticfiles',
 'octonet',
 'hostqueue.apps.HostQueue',
 'firewall.apps.Firewall',
 'dhcp.apps.Dhcp',
 'dansguardian.apps.DansGuardian',
 'host.apps.Host',
 'polygen.apps.Polygen',
 'upgrade.apps.Upgrade',
 'asterisk.apps.Asterisk',
 'samba.apps.Samba',
 'users.apps.Users',
 'script.apps.Script',
 'quota.apps.Quota',
 'printers.apps.Printers',
 'auth.apps.Auth']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'octonet.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:
File "/usr/lib/python3/dist-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3/dist-packages/django/views/generic/base.py" in view
  71.             return self.dispatch(request, *args, **kwargs)
File "/usr/share/octonet/octonet/mixins.py" in dispatch
  105.         return super().dispatch(request, *args, **kw)
File "/usr/lib/python3/dist-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)
File "/usr/lib/python3/dist-packages/django/views/generic/base.py" in get
  158.         context = self.get_context_data(**kwargs)
File "/usr/share/octonet/octonet/views.py" in get_context_data
  141.         ctx['filesystems'] = root.get("filesystems")
File "/usr/lib/python3/dist-packages/octofuss/tree.py" in get
  50.         return self.lget(_tolist(path), **kw)
File "/usr/lib/python3/dist-packages/octofuss/tree.py" in lget
  157.         return self.tree.lget(self.root + path, **kw)
File "/usr/lib/python3/dist-packages/octofuss/xmlrpc.py" in lget
  60.         return self._wrap_call(self.server.get, "/".join(path))
File "/usr/lib/python3/dist-packages/octofuss/xmlrpc.py" in _wrap_call
  42.                 raise globals().get(name, UnknownException)(msg)

Exception Type: UnknownException at /
Exception Value: 'filesystems'

#4 Updated by Christopher R. Gabriel over 4 years ago

  • Status changed from Risolto to Chiuso

Apro nuovo ticket, per cortesia un problema un ticket.

Also available in: Atom PDF