From d7303ec37b7bcd7f4d5eb2a6ffadd0ae790c1413 Mon Sep 17 00:00:00 2001 From: Sanj B Date: Sat, 24 Dec 2011 20:49:16 +0530 Subject: [PATCH] show translation strings in table --- manifests/ships/views.py | 9 ++++++--- manifests/templates/translate.html | 12 +++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/manifests/ships/views.py b/manifests/ships/views.py index d0608ea..d5a44ff 100644 --- a/manifests/ships/views.py +++ b/manifests/ships/views.py @@ -18,7 +18,7 @@ def translate(request, model, field): m = models.__getattribute__(model) except AttributeError: return HttpResponse("no such model") - response = '' + response = [] if field not in m._meta.get_all_field_names(): return HttpResponse("no such field") qset = m.objects.values(field).distinct() @@ -39,9 +39,12 @@ def translate(request, model, field): isEnglish = False ordArr.append(str(ord(char))) if not isEnglish: - response += "%s\n\n" % (val,) + response.append({ + 'ord': ordArr.join(","), + 'val': val + }) context = RequestContext(request, { - 'txt': response, + 'values': response, 'model': model, 'field': field }) diff --git a/manifests/templates/translate.html b/manifests/templates/translate.html index c92f20f..7510716 100644 --- a/manifests/templates/translate.html +++ b/manifests/templates/translate.html @@ -12,9 +12,15 @@ function googleTranslateElementInit() { }, 'google_translate_element'); } - {{ txt|linebreaksbr|safe }} - -


+ + {% for v in values %} + + + + + {% endfor %} +
{{ v.ord }}{{ v.val }}
+

{% csrf_token %}