Bug 6464

Summary: Add inconsistence check for '%s' count in tmpl_process3.pl
Product: Koha Reporter: Sébastien Marie <semarie>
Component: I18N/L10NAssignee: Frédéric Demians <f.demians>
Status: CLOSED FIXED QA Contact: Bugs List <koha-bugs>
Severity: enhancement    
Priority: PATCH-Sent (DO NOT USE) CC: chris, conan
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: inconsistence check for tmpl_process3.pl
git patch: check consistency of PO messages
Proposed patch
Signed-off patch

Description Sébastien Marie 2011-06-05 17:09:42 UTC Comment hidden (obsolete)
Comment 1 Frédéric Demians 2011-06-05 19:35:55 UTC
> This check could be easily be added just after PO loading, in 
> tmpl_process3.pl.

I agree. Could your submit that as a git patch I can sign off. Thanks.
Comment 2 Sébastien Marie 2011-06-06 11:01:22 UTC Comment hidden (obsolete)
Comment 3 Frédéric Demians 2011-06-06 12:46:00 UTC Comment hidden (obsolete)
Comment 4 Frédéric Demians 2011-06-06 12:48:16 UTC
I have modified your patch.

Display a warning for strings that don't have the same count of %s
placeholders that the English original strings. Don't warn for not
translated string and 'fuzzy' string because those strings are not
installed, and this is the translator responsibility to examine them.
    
Please test this patch and sign it off. Thanks.
Comment 5 Sébastien Marie 2011-06-06 13:21:02 UTC
Created attachment 4378 [details] [review]
Signed-off patch

It works great (and better warnings for user).

Thanks.
Comment 6 Fernando L. Canizo 2011-06-06 22:12:39 UTC
I applied the patch to an updated 3.4.x based branch, modified a working .po file to have inconsistent number of '%s' and run 'translate install es-ES', no warning was issued, script ended ok claiming: "The install seems to be successful."

Was it not the proper way to test it?
Comment 7 Sébastien Marie 2011-06-07 04:55:40 UTC
When inconsistences are found, only warnings are issued, not a blocking error. So only messages are showed, and at the beginning of process:

--- BEGIN extract of "translate install fr-FR" ---
Install templates
  Install templates 'opac
    From: /srv/koha/koha-git-tree/koha-tmpl/opac-tmpl/prog/en/
    To  : /srv/koha/koha-git-tree/koha-tmpl/opac-tmpl/prog/fr-FR
    With: /srv/koha/koha-git-tree/misc/translator/po/fr-FR-i-opac-t-prog-v-3002000.po
Charset in/out: UTF-8 at /srv/koha/koha-git-tree/misc/translator/tmpl_process3.pl line 268.
tmpl_process3.pl: Warning: unconsistent %s count: (2/1):
  line:   7913
  msgid:  "Enter your User ID%s and password%s, and click the submit button (or press the enter key)."
  msgstr: "Entrez votre identifiant adhérent%s et mot de passe, puis cliquez sur le bouton \"Soumettre\" (ou appuyez sur la tou
che <Entrée>)"
tmpl_process3.pl: Warning: unconsistent %s count: (12/10):
  line:   12190
  msgid:  "The %s most checked-out %s %s %s titles%s %s at %s %s %s in the past %s months %s of all time%s "
  msgstr: "Les %s plus empruntés %s %s %s documents à %s %s %s dans les %s derniers mois %s depuis le commencement%s "
tmpl_process3.pl: Warning: unconsistent %s count: (1/0):
  line:   10094
  msgid:  "Note: you can only delete your own tags. %sNote: your tag contained markup code that was removed. "
  msgstr: "Note&nbsp;: votre tag contenait du texte qui a été supprimé. "
Copying /srv/koha/koha-git-tree/koha-tmpl/opac-tmpl/prog/en/css/sanop.css...
Copying /srv/koha/koha-git-tree/koha-tmpl/opac-tmpl/prog/en/css/print.css...
Copying /srv/koha/koha-git-tree/koha-tmpl/opac-tmpl/prog/en/css/colors.css...
[...]
The install seems to be successful.
--- END ---

Could you verify if warning are present between:
 "Charset in/out: ..."
and
 "Copying ..." (or "Creating ...") ?

In order to grab all output in a file (message and warnings), you could redirect stdout and stderr in a file, using:
> ./translate install es-ES 2>&1 | tee ~/bug6464-output.txt
Comment 8 Chris Cormack 2011-06-09 07:54:10 UTC
Pushed please test
Comment 9 Sébastien Marie 2011-07-03 05:18:52 UTC
Thanks