Skip to content

Commit c775b35

Browse files
mjbarrera8Manuel Jesús Barrera Pozo
authored andcommitted
Added i18n
1 parent b0dedc7 commit c775b35

File tree

10 files changed

+94
-82
lines changed

10 files changed

+94
-82
lines changed

prettyjson/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__version__ = '0.4.1'
22

3-
from .widgets import PrettyJSONWidget
3+
from .widgets import PrettyJSONWidget # noqa
234 Bytes
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# English translation for django-prettyjson.
2+
# Copyright (C) 2024
3+
# This file is distributed under the same license as the django-prettyjson package.
4+
# Manuel Jesus Barrera <mj.barrera8@gmail.com>, 2024.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2023-03-02 12:29+0000\n"
10+
"PO-Revision-Date: 2018-07-04 21:21+0200\n"
11+
"Language: en\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: 8bit\n"
14+
"Generated-By: xls-to-po 1.0\n"
15+
16+
#: prettyjson/widgets.py:27
17+
msgid "Show parsed"
18+
msgstr ""
19+
20+
#: prettyjson/widgets.py:28
21+
msgid "Show raw"
22+
msgstr ""
23+
24+
#: prettyjson/widgets.py:29
25+
msgid "Collapse"
26+
msgstr ""
27+
28+
#: prettyjson/widgets.py:30
29+
msgid "Expand"
30+
msgstr ""
556 Bytes
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Spanish translation for django-prettyjson.
2+
# Copyright (C) 2024
3+
# This file is distributed under the same license as the django-prettyjson package.
4+
# Manuel Jesus Barrera <mj.barrera8@gmail.com>, 2024.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PACKAGE VERSION\n"
9+
"Report-Msgid-Bugs-To: \n"
10+
"POT-Creation-Date: 2023-03-02 12:29+0000\n"
11+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language-Team: LANGUAGE <LL@li.org>\n"
14+
"Language: es\n"
15+
"MIME-Version: 1.0\n"
16+
"Content-Type: text/plain; charset=UTF-8\n"
17+
"Content-Transfer-Encoding: 8bit\n"
18+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19+
20+
#: prettyjson/widgets.py:27
21+
msgid "Show parsed"
22+
msgstr "Mostrar procesado"
23+
24+
#: prettyjson/widgets.py:28
25+
msgid "Show raw"
26+
msgstr "Mostrar sin procesar"
27+
28+
#: prettyjson/widgets.py:29
29+
msgid "Collapse"
30+
msgstr "Colapsar"
31+
32+
#: prettyjson/widgets.py:30
33+
msgid "Expand"
34+
msgstr "Expandir"

prettyjson/static/prettyjson/prettyjson.css

Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prettyjson/static/prettyjson/prettyjson.js

Lines changed: 1 addition & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prettyjson/templatetags/prettyjson.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def prettyjson(obj, name="", **kwargs):
2727
data = obj
2828
if isinstance(obj, six.string_types):
2929
data = json.loads(obj)
30+
3031
widget = PrettyJSONWidget(attrs=kwargs)
31-
return mark_safe(widget.render(name=name,
32-
value=(json.dumps(data, ensure_ascii=False, cls=StandardJSONEncoder)),
33-
attrs=widget.attrs))
32+
return mark_safe(
33+
widget.render(
34+
name=name,
35+
value=(json.dumps(data, ensure_ascii=False, cls=StandardJSONEncoder)),
36+
attrs=widget.attrs
37+
)
38+
)

prettyjson/widgets.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import django
2+
13
from django.conf import settings
24
from django.forms import widgets
35

6+
if django.VERSION >= (2, 0, 0):
7+
from django.utils.translation import gettext as _
8+
else:
9+
from django.utils.translation import ugettext as _
10+
411

512
class PrettyJSONWidget(widgets.Textarea):
613

@@ -14,11 +21,16 @@ def render(self, name, value, attrs=None, **kwargs):
1421
if (start_as not in self._allowed_attrs()):
1522
start_as = self.DEFAULT_ATTR
1623

17-
return ('<div class="jsonwidget" data-initial="' + start_as + '"><p><button class="parseraw" '
18-
'type="button">Show parsed</button> <button class="parsed" '
19-
'type="button">Collapse all</button> <button class="parsed" '
20-
'type="button">Expand all</button></p>' + html + '<div '
21-
'class="parsed"></div></div>')
24+
return (
25+
'<div class="jsonwidget" data-initial="' + start_as + '"> '
26+
'<p> '
27+
'<button class="parseraw btn-parsed" type="button">' + _("Show parsed") + '</button> '
28+
'<button class="parsed btn-raw" type="button">' + _("Show raw") + '</button> '
29+
'<button class="parsed btn-collapse" type="button">' + _("Collapse") + '</button> '
30+
'<button class="parsed btn-expand" type="button">' + _("Expand") + '</button> '
31+
'</p>' + html + '<div class="parsed"></div> '
32+
'</div>'
33+
)
2234

2335
@staticmethod
2436
def _allowed_attrs():

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ def get_version(*file_paths):
1919
return version_match.group(1)
2020
raise RuntimeError('Unable to find version string.')
2121

22+
2223
version = get_version('prettyjson', '__init__.py')
2324

2425
if sys.argv[-1] == 'publish':
2526
try:
26-
import wheel
27+
import wheel # noqa
2728
except ImportError:
2829
print('Wheel library missing. Please run "pip install wheel"')
2930
sys.exit()

0 commit comments

Comments
 (0)