From 84c24dc1c726e98a69918d6502bdeac14c6c59ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 28 Feb 2012 16:01:07 +0100 Subject: [PATCH] Show links to source files --- html/translate.html | 2 +- trans/models.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/html/translate.html b/html/translate.html index d723b1857..babe19aab 100644 --- a/html/translate.html +++ b/html/translate.html @@ -19,7 +19,7 @@ {% else %} {{ unit.source }}{{ form.target }} {% endif %} -{{ unit.location }} +{{ unit.get_location_links }} {% trans "Skip" %} diff --git a/trans/models.py b/trans/models.py index 0efd79c4f..73ee444dc 100644 --- a/trans/models.py +++ b/trans/models.py @@ -3,6 +3,7 @@ from django.db.models import Q from django.conf import settings from lang.models import Language from django.utils.translation import ugettext_lazy, ugettext as _ +from django.utils.safestring import mark_safe from glob import glob import os import os.path @@ -363,3 +364,13 @@ class Unit(models.Model): else: del kwargs['backend'] super(Unit, self).save(*args, **kwargs) + + def get_location_links(self): + ret = [] + for location in self.location.split(','): + location = location.strip() + filename, line = location.split(':') + link = 'https://github.com/phpmyadmin/phpmyadmin/blob/master/%s#L%s' % (filename, line) + ret.append('%s' % (link, location)) + return mark_safe('\n'.join(ret)) +