Patchwork [stable,v2] hgweb, i18n: avoid parameterized search mode description

login
register
mail settings
Submitter Wagner Bruna
Date Nov. 4, 2013, 7:46 p.m.
Message ID <d431f97c7dea5cd8f68b.1383594405@mwagner.paulista.local>
Download mbox | patch
Permalink /patch/2848/
State Superseded
Headers show

Comments

Wagner Bruna - Nov. 4, 2013, 7:46 p.m.
# HG changeset patch
# User Wagner Bruna <wbruna@softwareexpress.com.br>
# Date 1383572580 7200
#      Seg Nov 04 11:43:00 2013 -0200
# Branch stable
# Node ID d431f97c7dea5cd8f68bea8364c83d24d3b5e97e
# Parent  84755bf5946968fdb7d8bd0951b9238346ef268e
hgweb, i18n: avoid parameterized search mode description

The search mode description can't be translated by itself, since
it's displayed as part of an English-only template phrase (the
"Assuming ..." / "Use ... instead" bits). We shoud either translate
and display the whole phrases at once, or simply drop the
translation markers on the descriptions (since our templates are
currently English-only anyway).
Matt Mackall - Nov. 4, 2013, 8:51 p.m.
On Mon, 2013-11-04 at 17:46 -0200, Wagner Bruna wrote:

> Let me get this out of the way first: IMHO it's EXTREMELY inefficient to
> approach a communication problem with further non-communication.

For future reference, "???" = "I am utterly mystified by this patch." 

The problem here was that I didn't spot the "Assuming {blah}" in the
templates and "parameterized" didn't suggest "bogus translation of
string fragments" to me.

> The search mode description can't be translated by itself, since
> it's displayed as part of an English-only template phrase (the
> "Assuming ..." / "Use ... instead" bits). We shoud either translate
> and display the whole phrases at once, or simply drop the
> translation markers on the descriptions (since our templates are
> currently English-only anyway).

Ok. Frankly leaning towards not translating, especially given the test
output changes. When we've tackled translation of the boring static
parts of hgweb, we can revisit this.

If anyone's interested in this, a good first step towards that goal is
adding a template syntax for translatables that it can no-op for now.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -151,9 +151,15 @@  def _search(web, req, tmpl):
             yield web.repo[r]
 
     searchfuncs = {
-        MODE_REVISION: (revsearch, _('exact revision search')),
-        MODE_KEYWORD: (keywordsearch, _('literal keyword search')),
-        MODE_REVSET: (revsetsearch, _('revset expression search')),
+        MODE_REVISION: (revsearch,
+                        _('Assuming exact revision search.'),
+                        _('Use exact revision search instead.')),
+        MODE_KEYWORD: (keywordsearch,
+                       _('Assuming literal keyword search.'),
+                       _('Use literal keyword search instead.')),
+        MODE_REVSET: (revsetsearch,
+                       _('Assuming revset expression search.'),
+                       _('Use revset expression search instead.')),
     }
 
     def getsearchmode(query):
@@ -243,12 +249,12 @@  def _search(web, req, tmpl):
 
     if 'forcekw' in req.form:
         showforcekw = ''
-        showunforcekw = searchfuncs[mode][1]
+        showunforcekw = searchfuncs[mode][2]
         mode = MODE_KEYWORD
         funcarg = query
     else:
         if mode != MODE_KEYWORD:
-            showforcekw = searchfuncs[MODE_KEYWORD][1]
+            showforcekw = searchfuncs[MODE_KEYWORD][2]
         else:
             showforcekw = ''
         showunforcekw = ''
diff --git a/mercurial/templates/paper/search.tmpl b/mercurial/templates/paper/search.tmpl
--- a/mercurial/templates/paper/search.tmpl
+++ b/mercurial/templates/paper/search.tmpl
@@ -24,11 +24,11 @@ 
 <h3>searching for '{query|escape}'</h3>
 
 <p>
-Assuming {modedesc}.
+{modedesc}
 {if(showforcekw, '<a href="{url|urlescape}log?rev={query|urlescape}&forcekw=1">
-Use {showforcekw}</a> instead.')}
+{showforcekw}</a>')}
 {if(showunforcekw, '<a href="{url|urlescape}log?rev={query|urlescape}">
-Use {showunforcekw}</a> instead.')}
+{showunforcekw}</a>')}
 </p>
 
 <form class="search" action="{url|urlescape}log">
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -570,7 +570,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "tip^"
-  # Mode revset expression search
+  # Mode Assuming revset expression search.
   
   changeset:   1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe
   revision:    2
@@ -587,7 +587,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "last(all(),2)^"
-  # Mode revset expression search
+  # Mode Assuming revset expression search.
   
   changeset:   1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe
   revision:    2
@@ -611,7 +611,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "last(all(,2)^"
-  # Mode literal keyword search
+  # Mode Assuming literal keyword search.
   
   
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'log?rev=last(al(),2)^&style=raw'
@@ -621,7 +621,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "last(al(),2)^"
-  # Mode literal keyword search
+  # Mode Assuming literal keyword search.
   
   
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'log?rev=bookmark(anotherthing)&style=raw'
@@ -631,7 +631,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "bookmark(anotherthing)"
-  # Mode revset expression search
+  # Mode Assuming revset expression search.
   
   changeset:   2ef0ac749a14e4f57a5a822464a0902c6f7f448f
   revision:    0
@@ -649,7 +649,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "bookmark(abc)"
-  # Mode literal keyword search
+  # Mode Assuming literal keyword search.
   
   
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'log?rev=deadbeef:&style=raw'
@@ -659,7 +659,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "deadbeef:"
-  # Mode literal keyword search
+  # Mode Assuming literal keyword search.
   
   
 
@@ -670,7 +670,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "user("test")"
-  # Mode revset expression search
+  # Mode Assuming revset expression search.
   
   changeset:   cad8025a2e87f88c06259790adfa15acb4080123
   revision:    3
@@ -711,7 +711,7 @@  Search with revset syntax
   # HG changesets search
   # Node ID cad8025a2e87f88c06259790adfa15acb4080123
   # Query "user("re:test")"
-  # Mode literal keyword search
+  # Mode Assuming literal keyword search.