Browse Source

HUE-762 [jb] backend i18n

Enrico Berti 13 years ago
parent
commit
70b53ae

+ 3 - 3
apps/jobbrowser/src/jobbrowser/conf.py

@@ -17,11 +17,11 @@
 """Configuration for the job browser application"""
 
 from desktop.lib.conf import Config, coerce_bool
-
+from django.utils.translation import ugettext_lazy as _
 
 SHARE_JOBS = Config(
   key='share_jobs',
   default=True,
   type=coerce_bool,
-  help='Share submitted jobs information with all users. If set to false, '
-       'submitted jobs are visible only to the owner and administrators.')
+  help=_('Share submitted jobs information with all users. If set to false, '
+       'submitted jobs are visible only to the owner and administrators.'))

+ 63 - 1
apps/jobbrowser/src/jobbrowser/locale/django.pot

@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PROJECT VERSION\n"
 "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2012-07-02 22:40+0200\n"
+"POT-Creation-Date: 2012-07-10 14:02+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,6 +17,64 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 0.9.6\n"
 
+#: src/jobbrowser/conf.py:26
+msgid ""
+"Share submitted jobs information with all users. If set to false, "
+"submitted jobs are visible only to the owner and administrators."
+msgstr ""
+
+#: src/jobbrowser/models.py:79
+#, python-format
+msgid "could not find job with id %(id)s"
+msgstr ""
+
+#: src/jobbrowser/models.py:402
+#, python-format
+msgid "Cannot lookup TaskTracker '%(id)s'"
+msgstr ""
+
+#: src/jobbrowser/models.py:426
+#, python-format
+msgid "Cannot retrieve logs from TaskTracker '%(id)s'"
+msgstr ""
+
+#: src/jobbrowser/models.py:433
+#, python-format
+msgid "Hue encountered an error while retrieving logs from '%(url)s'"
+msgstr ""
+
+#: src/jobbrowser/views.py:60
+#, python-format
+msgid "You don't have the permissions to access job %(id)s"
+msgstr ""
+
+#: src/jobbrowser/views.py:131
+#, python-format
+msgid "kill_job may only be invoked with a POST (got a %(method)s)"
+msgstr ""
+
+#: src/jobbrowser/views.py:134
+msgid "Insufficient permission"
+msgstr ""
+
+#: src/jobbrowser/views.py:135
+#, python-format
+msgid "Permission denied.  User %(username)s cannot delete user %(user)s's job."
+msgstr ""
+
+#: src/jobbrowser/views.py:151
+msgid "Job did not appear as killed within 15 seconds"
+msgstr ""
+
+#: src/jobbrowser/views.py:229
+#, python-format
+msgid "Cannot find attempt '%(id)s' in task"
+msgstr ""
+
+#: src/jobbrowser/views.py:240
+msgid "Failed to retrieve log. TaskTracker not found."
+msgstr ""
+
 #: src/jobbrowser/templates/attempt.mako:22
 #: src/jobbrowser/templates/attempt.mako:24
 #, python-format
@@ -560,3 +618,7 @@ msgstr ""
 msgid "Max Reduce Tasks"
 msgstr ""
 
+#: src/jobbrowser/templatetags/unix_ms_to_datetime.py:29
+msgid "No time"
+msgstr ""
+

+ 63 - 1
apps/jobbrowser/src/jobbrowser/locale/en_US/LC_MESSAGES/django.po

@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PROJECT VERSION\n"
 "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2012-07-02 22:40+0200\n"
+"POT-Creation-Date: 2012-07-10 14:02+0200\n"
 "PO-Revision-Date: 2012-07-02 21:29+0200\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: en_US <LL@li.org>\n"
@@ -17,6 +17,64 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 0.9.6\n"
 
+#: src/jobbrowser/conf.py:26
+msgid ""
+"Share submitted jobs information with all users. If set to false, "
+"submitted jobs are visible only to the owner and administrators."
+msgstr ""
+
+#: src/jobbrowser/models.py:79
+#, python-format
+msgid "could not find job with id %(id)s"
+msgstr ""
+
+#: src/jobbrowser/models.py:402
+#, python-format
+msgid "Cannot lookup TaskTracker '%(id)s'"
+msgstr ""
+
+#: src/jobbrowser/models.py:426
+#, python-format
+msgid "Cannot retrieve logs from TaskTracker '%(id)s'"
+msgstr ""
+
+#: src/jobbrowser/models.py:433
+#, python-format
+msgid "Hue encountered an error while retrieving logs from '%(url)s'"
+msgstr ""
+
+#: src/jobbrowser/views.py:60
+#, python-format
+msgid "You don't have the permissions to access job %(id)s"
+msgstr ""
+
+#: src/jobbrowser/views.py:131
+#, python-format
+msgid "kill_job may only be invoked with a POST (got a %(method)s)"
+msgstr ""
+
+#: src/jobbrowser/views.py:134
+msgid "Insufficient permission"
+msgstr ""
+
+#: src/jobbrowser/views.py:135
+#, python-format
+msgid "Permission denied.  User %(username)s cannot delete user %(user)s's job."
+msgstr ""
+
+#: src/jobbrowser/views.py:151
+msgid "Job did not appear as killed within 15 seconds"
+msgstr ""
+
+#: src/jobbrowser/views.py:229
+#, python-format
+msgid "Cannot find attempt '%(id)s' in task"
+msgstr ""
+
+#: src/jobbrowser/views.py:240
+msgid "Failed to retrieve log. TaskTracker not found."
+msgstr ""
+
 #: src/jobbrowser/templates/attempt.mako:22
 #: src/jobbrowser/templates/attempt.mako:24
 #, python-format
@@ -560,3 +618,7 @@ msgstr ""
 msgid "Max Reduce Tasks"
 msgstr ""
 
+#: src/jobbrowser/templatetags/unix_ms_to_datetime.py:29
+msgid "No time"
+msgstr ""
+

+ 6 - 4
apps/jobbrowser/src/jobbrowser/models.py

@@ -29,6 +29,8 @@ import urllib2
 
 import hadoop.api.jobtracker.ttypes as ttypes
 
+from django.utils.translation import ugettext as _
+
 LOGGER = logging.getLogger(__name__)
 
 class JobLinkage(object):
@@ -74,7 +76,7 @@ class Job(JobLinkage):
     """
     thriftjob = jt.get_job(jt.thriftjobid_from_string(jobid))
     if not thriftjob:
-      raise Exception("could not find job with id %s" % jobid)
+      raise Exception(_("Could not find job with id %(id)s") % dict(id=jobid))
     return Job(jt, thriftjob)
 
   @staticmethod
@@ -397,7 +399,7 @@ class TaskAttempt(object):
         for t in all_trackers.trackers:
           LOGGER.debug("Available tracker: %s" % (t.trackerName,))
       raise ttypes.TaskTrackerNotFoundException(
-                          "Cannot lookup TaskTracker '%s'" % (self.taskTrackerId,))
+                          _("Cannot lookup TaskTracker '%(id)s'") % dict(id=self.taskTrackerId))
 
   def get_task_log(self):
     """
@@ -421,14 +423,14 @@ class TaskAttempt(object):
     try:
       data = urllib2.urlopen(url)
     except urllib2.URLError:
-      raise urllib2.URLError("Cannot retrieve logs from TaskTracker '%s'" % (self.taskTrackerId,))
+      raise urllib2.URLError(_("Cannot retrieve logs from TaskTracker '%(id)s'") % dict(id=self.taskTrackerId))
 
     et = lxml.html.parse(data)
     log_sections = et.findall('body/pre')
     if len(log_sections) != 3:
       LOGGER.warn('Error parsing task attempt log for %s at "%s". Found %d (not 3) log sections' %
                   (self.attemptId, url, len(log_sections)))
-      err = "Hue encountered an error while retrieving logs from '%s'" % (url,)
+      err = _("Hue encountered an error while retrieving logs from '%(url)s'") % dict(url=url)
       return (err, err, err)
     return [ section.text for section in log_sections ]
 

+ 2 - 1
apps/jobbrowser/src/jobbrowser/templatetags/unix_ms_to_datetime.py

@@ -17,6 +17,7 @@
 
 import datetime
 import django
+from django.utils.translation import ugettext as _
 
 register = django.template.Library()
 
@@ -25,7 +26,7 @@ def unix_ms_to_datetime(unixtime):
   """unixtime is seconds since the epoch"""
   if unixtime:
     return datetime.datetime.fromtimestamp(unixtime/1000)
-  return "No time"
+  return _("No time")
 unix_ms_to_datetime.is_safe = True
 
 

+ 11 - 9
apps/jobbrowser/src/jobbrowser/views.py

@@ -39,6 +39,8 @@ from hadoop.api.jobtracker.ttypes import TaskTrackerNotFoundException
 from jobbrowser import conf
 from jobbrowser.models import Job, JobLinkage, TaskList, Tracker, Cluster
 
+from django.utils.translation import ugettext as _
+
 ##################################
 ## View end-points
 
@@ -55,8 +57,8 @@ def check_job_permission(view_func):
     job = Job.from_id(jt=request.jt, jobid=jobid)
     if not conf.SHARE_JOBS.get() and not request.user.is_superuser \
       and job.user != request.user.username:
-      raise PopupException("You don't have the permissions to access"
-                             " job %s" % jobid)
+      raise PopupException(_("You don't have the permissions to access"
+                             " job %(id)s") % dict(id=jobid))
     return view_func(request, *args, **kwargs)
   return wraps(view_func)(decorate)
 
@@ -126,12 +128,12 @@ def kill_job(request, jobid):
   We get here from /jobs/jobid/kill
   """
   if request.method != "POST":
-    raise Exception("kill_job may only be invoked with a POST (got a %s)" % request.method)
+    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s)") % dict(method=request.method))
   job = Job.from_id(jt=request.jt, jobid=jobid)
   if job.user != request.user.username and not request.user.is_superuser:
-    access_warn(request, 'Insufficient permission')
-    raise MessageException("Permission denied.  User %s cannot delete user %s's job." %
-                           (request.user.username, job.user))
+    access_warn(request, _('Insufficient permission'))
+    raise MessageException(_("Permission denied.  User %(username)s cannot delete user %(user)s's job.") %
+                           dict(username=request.user.username, user=job.user))
 
   job.kill()
   cur_time = time.time()
@@ -146,7 +148,7 @@ def kill_job(request, jobid):
     time.sleep(1)
     job = Job.from_id(jt=request.jt, jobid=jobid)
 
-  raise Exception("Job did not appear as killed within 15 seconds")
+  raise Exception(_("Job did not appear as killed within 15 seconds"))
 
 @check_job_permission
 def tasks(request, jobid):
@@ -224,7 +226,7 @@ def single_task_attempt(request, jobid, taskid, attemptid):
   try:
     attempt = task.get_attempt(attemptid)
   except KeyError:
-    raise KeyError("Cannot find attempt '%s' in task" % (attemptid,))
+    raise KeyError(_("Cannot find attempt '%(id)s' in task") % dict(id=attemptid))
 
   try:
     # Add a diagnostic log
@@ -235,7 +237,7 @@ def single_task_attempt(request, jobid, taskid, attemptid):
   except TaskTrackerNotFoundException:
     # Four entries,
     # for diagnostic, stdout, stderr and syslog
-    logs = [ "Failed to retrieve log. TaskTracker not found." ] * 4
+    logs = [ _("Failed to retrieve log. TaskTracker not found.") ] * 4
   return render("attempt.mako", request,
     {
       "attempt":attempt,