Bug 13794 - Text input field values not translated
Summary: Text input field values not translated
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Maxime Beaulieu
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-04 22:07 UTC by Maxime Beaulieu
Modified: 2015-12-03 22:03 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Fixed logical test in tmpl_process3.pl (2.23 KB, patch)
2015-03-04 22:10 UTC, Maxime Beaulieu
Details | Diff | Splinter Review
Added "submit" in the list of input types. (1.11 KB, patch)
2015-03-05 19:02 UTC, Maxime Beaulieu
Details | Diff | Splinter Review
Bug 13794 - New patch, the old patches were likely to cause regression issues. (1.24 KB, patch)
2015-03-05 22:02 UTC, Maxime Beaulieu
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 13794: Text input field values not translated (1.61 KB, patch)
2015-03-10 14:59 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 13794: Text input field values not translated (1.65 KB, patch)
2015-03-11 16:14 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Beaulieu 2015-03-04 22:07:11 UTC
The template translation tool does not translate input field values.
I have fixed a logical test marked by a #FIXME tag in tmpl_process3.pl.
Comment 1 Maxime Beaulieu 2015-03-04 22:10:58 UTC Comment hidden (obsolete)
Comment 2 Maxime Beaulieu 2015-03-05 19:02:35 UTC Comment hidden (obsolete)
Comment 3 Maxime Beaulieu 2015-03-05 22:02:05 UTC Comment hidden (obsolete)
Comment 4 Bernardo Gonzalez Kriegel 2015-03-06 19:04:47 UTC
Hi Maxime

Is the patch ready to sign?

I tried it anyway, I found no difference on translation files
with the patch, have you an example of same untranslated text?

Regards, Bernardo
Comment 5 Maxime Beaulieu 2015-03-06 20:03:56 UTC
Changes will only appear if the template you are generating contains:

<input type="text" name="translate" value="I wish to translate this">

And in the .po file:

#. INPUT type=text name=translate
#: pathToTemplate:lineNumber
msgid "I wish to translate this"
msgstr "Translated!"

Without the patch tmpl_process3 will skip translation the value of the text input.
With the patch the value is translated.

In my case, the untranslated text appeared in a customized template.
I figured I would put a word out on the possible issue just in case.
Comment 6 Bernardo Gonzalez Kriegel 2015-03-10 11:10:39 UTC
(In reply to Maxime Beaulieu from comment #5)
> Changes will only appear if the template you are generating contains:
> 
> <input type="text" name="translate" value="I wish to translate this">
> 
> And in the .po file:
> 
> #. INPUT type=text name=translate
> #: pathToTemplate:lineNumber
> msgid "I wish to translate this"
> msgstr "Translated!"
> 
> Without the patch tmpl_process3 will skip translation the value of the text
> input.
> With the patch the value is translated.
> 
> In my case, the untranslated text appeared in a customized template.
> I figured I would put a word out on the possible issue just in case.

Hi again, I found the following on current master:
1) Update a language 
2) Add an input type 'text' as suggested

e.g. on the first form of 'admin-home.tt',
<input type="text" name="translate" value="I wish to translate this">

3) Update again the language and diff staff PO file

+#. INPUT type=text name=translate
+#: intranet-tmpl/prog/en/modules/admin/admin-home.tt:25
+#, fuzzy
+msgid "I wish to translate this"
+msgstr "Título traducido: "

And this "without" your patch!!
Could you confirm?
Comment 7 Maxime Beaulieu 2015-03-10 12:46:54 UTC
Hi Bernardo,

The PO's are generated correctly, but the translation does not apply to the templates when 'translate install' is run.

TEST:
 Create custom text input in the template fo your choice
  <input type="text" name="translate" value="I wish to translate this">
 Run 'translate update [lang]'
 Check the appropriate [lang] po file and edit the translation for your input.
 Run 'translate install [lang]', the translated string does not appear.
 Apply the patch. Run 'translate install [lang]. The input is translated.
Comment 8 Bernardo Gonzalez Kriegel 2015-03-10 14:59:00 UTC Comment hidden (obsolete)
Comment 9 Jonathan Druart 2015-03-11 16:08:49 UTC
I can confirm the patch work, but I cannot be sure it won't introduce regression

The "text" have been added by 
commit db1660f512c52a9c848489f4e2e56516e99e1567
Author: acli <acli>
Date:   Mon Mar 8 04:59:38 2004 +0000

    Fixed some bugs which caused some context to be not recognized, and some
    spurious context to be recognized.  In particular, the bugs fixed are:
    
    1. Failure to recognize INPUT element at the end, e.g., if the input has
       the form "Item number:%S", then the pattern was recognized as only
       "Item number".
    
    2. Failure to remove matching <foo></foo> tags if the pattern contains
       INPUT or TMPL_VAR; e.g., if the input has the form "<h1>%s %s</h1>",
       the form would not be simplified to "%s %s".
    
    Unfortunately, fixing these 2 bugs will cause about 40 fuzzies to appear.

But it did a lot of other stuffs.
Comment 10 Jonathan Druart 2015-03-11 16:14:05 UTC
Ok so, I tried to be sure no regression is added:

$ git checkout bug_13794
$ cd misc/translator
$ perl update es-ES
$ perl install es-ES
$ cp -r po/es-ES-i-staff-t-prog-v-3006000.po po/es-ES-opac-bootstrap.po po/es-ES-pref.po po/es-ES-staff-help.po ../../koha-tmpl/intranet-tmpl/prog/es-ES/ ../../koha-tmpl/opac-tmpl/bootstrap/es-ES /tmp/test_bug_13794
$ cd /tmp/test_bug_13794
$ git init;git add .; git commit -m"something"
# back in my koha src
$ git checkout master
$ cd misc/translator
$ perl update es-ES
$ perl install es-ES
$ cp -r po/es-ES-i-staff-t-prog-v-3006000.po po/es-ES-opac-bootstrap.po po/es-ES-pref.po po/es-ES-staff-help.po ../../koha-tmpl/intranet-tmpl/prog/es-ES/ ../../koha-tmpl/opac-tmpl/bootstrap/es-ES /tmp/test_bug_13794
$ cd /tmp/test_bug_13794
$ git diff | grep input | grep text | grep value | grep -v 'value=""' | grep -v 'value="\[\%'| vim -

gives me the following:

 id="start_card" class="focus" title="Número de carné de inicio" size="5" name="start_card" value="1" />
- <label class="inline" for="basename">Nombre: </label> <input name="basename" value="Exportar" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label> <input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input value="Exportar" name="basename" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input name="basename" value="Exportar" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input type="text" id="basename" value="Exportar" name="basename" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input value="Exportar" name="basename" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input name="basename" value="Exportar" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input value="Exportar" name="basename" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input value="Exportar" name="basename" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input name="basename" value="Exportar" id="basename" type="text" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
- <label class="inline" for="basename">Nombre: </label><input name="basename" value="Exportar" type="text" id="basename" />
+ <label class="inline" for="basename">Nombre: </label><input type="text" name="basename" id="basename" value="Export" />
  con valor <input type="text" name="field_value" id="field_value" />
- <input value="Exportar" name="basename" type="text" id="basename" />
+ <input type="text" name="basename" id="basename" value="Export" />  

All looks good.
Comment 11 Jonathan Druart 2015-03-11 16:14:55 UTC
Created attachment 36816 [details] [review]
Bug 13794: Text input field values not translated

I left the code logic intact, and simply removed "text" from the regex.
Text input field values are now translated, no other logical changes are introduced.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Test:
1) Update, install and enable es-ES language
2) Go to Reports > Acquisition wizard
3) On page bottom, there is a text field with the word 'Export'
4) Switch language, the word is not translated
5) Apply the patch
6) Update and install again es-ES language
7) Reload page, text now reads 'Exportar'

No koha-qa errors.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 12 Tomás Cohen Arazi 2015-03-15 12:23:45 UTC
Patch pushed to master.

Thanks Maxime!
Comment 13 Chris Cormack 2015-03-21 22:04:44 UTC
Changes translations held for 3.18.6
Comment 14 Chris Cormack 2015-03-23 07:34:53 UTC
Pushed to 3.18.x will be in 3.18.6