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.
Created attachment 36514 [details] [review] Fixed logical test in tmpl_process3.pl The line: next if $a eq 'value' && ($tag ne 'input' || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/)); # FIXME This portion: (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/) checks if the input type is valid. We get the following (wrong) logic: next IF $a eq value AND the tag is not an input OR the input type is valid The test is true when : $a eq value, tag is an input, input type is valid We skip the tag when it is valid, it is never translated. I propose the following change: my $isValidType = ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/; next if $a eq 'value' && !($tag eq 'input' && $isValidType); next IF $a eq value AND NOT ( tag is an input AND input type is valid ) in short: NOT (tag is a valid input tag) [ Alternative ] ( Not included in patch ) next if $a eq 'value' && ($tag ne 'input' || (ref $attr->{'type'} && $attr->{'type'}->[1] !~ /^(?:checkbox|hidden|radio|text)$/)); No extra variable, at the cost of code readability.
Created attachment 36635 [details] [review] Added "submit" in the list of input types.
Created attachment 36637 [details] [review] Bug 13794 - New patch, the old patches were likely to cause regression issues. 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.
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
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.
(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?
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.
Created attachment 36767 [details] [review] [SIGNED-OFF] 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.
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.
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.
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>
Patch pushed to master. Thanks Maxime!
Changes translations held for 3.18.6
Pushed to 3.18.x will be in 3.18.6