Patchwork [RFC] blackbox: do not translate the log messages

login
register
mail settings
Submitter Durham Goode
Date Feb. 13, 2013, 9:38 p.m.
Message ID <9e42d1429fc278b83adb.1360791527@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/986/
State Accepted
Commit 4f485bd68f1debb88d5022a732d85c8c225e91fc
Headers show

Comments

Durham Goode - Feb. 13, 2013, 9:38 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1360788690 28800
#      Wed Feb 13 12:51:30 2013 -0800
# Node ID 9e42d1429fc278b83adb14e039f8fb4093048b0f
# Parent  dcef36a6f4e3f8dfd99987c8867209d40799277b
blackbox: do not translate the log messages

User 'timeless' in irc mentioned that having the blackbox be translated
would result in logs that:

- may be mixed language, if multiple users use the same repo
- are not google searchable (since searching for english gives more results)
- might not be readable by an admin if the employee is using hg in his native
language

And therefore we should log everything in english.

It seems weird to me to produce a log in english when the user chose a different
language. I don't know what mercurial's translation policy is, nor am I familiar
with foreign language use of software in general, so I wanted to throw this out
there for comment before I made the change.
Matt Mackall - Feb. 14, 2013, 1:29 a.m.
On Wed, 2013-02-13 at 13:38 -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1360788690 28800
> #      Wed Feb 13 12:51:30 2013 -0800
> # Node ID 9e42d1429fc278b83adb14e039f8fb4093048b0f
> # Parent  dcef36a6f4e3f8dfd99987c8867209d40799277b
> blackbox: do not translate the log messages
> 
> User 'timeless' in irc mentioned that having the blackbox be translated
> would result in logs that:
> 
> - may be mixed language, if multiple users use the same repo
> - are not google searchable (since searching for english gives more results)
> - might not be readable by an admin if the employee is using hg in his native
> language
> 
> And therefore we should log everything in english.
> 
> It seems weird to me to produce a log in english when the user chose a different
> language. I don't know what mercurial's translation policy is, nor am I familiar
> with foreign language use of software in general, so I wanted to throw this out
> there for comment before I made the change.

The blackbox is primarily intended for us by admins.. and us. So I think
English is preferable.

Check-code should complain about untranslated strings like this. The
usual pattern is to wrap untranslated strings in ("parentheses") to shut
it up.

> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -747,7 +747,7 @@
>          return ret
>      finally:
>          duration = time.time() - starttime
> -        ui.log("commandfinish", _("%s exited %s after %0.2f seconds\n"),
> +        ui.log("commandfinish", "%s exited %s after %0.2f seconds\n",
>                 cmd, ret, duration)
>          if repo and repo != req.repo:
>              repo.close()
> diff --git a/mercurial/hook.py b/mercurial/hook.py
> --- a/mercurial/hook.py
> +++ b/mercurial/hook.py
> @@ -98,7 +98,7 @@
>          readablefunc = funcname
>          if isinstance(funcname, types.FunctionType):
>              readablefunc = funcname.__module__ + "." + funcname.__name__
> -        ui.log('pythonhook', _('pythonhook-%s: %s finished in %0.2f seconds\n'),
> +        ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n',
>                 name, readablefunc, duration)
>      if r:
>          if throw:
> @@ -132,7 +132,7 @@
>          r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout)
>  
>      duration = time.time() - starttime
> -    ui.log('exthook', _('exthook-%s: %s finished in %0.2f seconds\n'),
> +    ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
>             name, cmd, duration)
>      if r:
>          desc, r = util.explainexit(r)
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -2402,7 +2402,7 @@
>  
>                      newheads = [h for h in self.heads() if h not in oldheads]
>                      self.ui.log("incoming",
> -                                _("%s incoming changes - new heads: %s\n"),
> +                                "%s incoming changes - new heads: %s\n",
>                                  len(added),
>                                  ', '.join([hex(c[:6]) for c in newheads]))
>                  self._afterlock(runhooks)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Bryan O'Sullivan - Feb. 14, 2013, 4:26 p.m.
On Wed, Feb 13, 2013 at 5:29 PM, Matt Mackall <mpm@selenic.com> wrote:

> Check-code should complain about untranslated strings like this.
>

I've applied the patch as-is. check-code doesn't care because it knows
nothing about ui.log.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -747,7 +747,7 @@ 
         return ret
     finally:
         duration = time.time() - starttime
-        ui.log("commandfinish", _("%s exited %s after %0.2f seconds\n"),
+        ui.log("commandfinish", "%s exited %s after %0.2f seconds\n",
                cmd, ret, duration)
         if repo and repo != req.repo:
             repo.close()
diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -98,7 +98,7 @@ 
         readablefunc = funcname
         if isinstance(funcname, types.FunctionType):
             readablefunc = funcname.__module__ + "." + funcname.__name__
-        ui.log('pythonhook', _('pythonhook-%s: %s finished in %0.2f seconds\n'),
+        ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n',
                name, readablefunc, duration)
     if r:
         if throw:
@@ -132,7 +132,7 @@ 
         r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout)
 
     duration = time.time() - starttime
-    ui.log('exthook', _('exthook-%s: %s finished in %0.2f seconds\n'),
+    ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
            name, cmd, duration)
     if r:
         desc, r = util.explainexit(r)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2402,7 +2402,7 @@ 
 
                     newheads = [h for h in self.heads() if h not in oldheads]
                     self.ui.log("incoming",
-                                _("%s incoming changes - new heads: %s\n"),
+                                "%s incoming changes - new heads: %s\n",
                                 len(added),
                                 ', '.join([hex(c[:6]) for c in newheads]))
                 self._afterlock(runhooks)