Skip to content

Commit

Permalink
Bug 6464 Check inconsistent placeholders in translated strings
Browse files Browse the repository at this point in the history
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 responsability to examine them.

Based on Frère Sébastien Marie work.

Signed-off-by: Frère Sébastien Marie <semarie-koha@latrappe.fr>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
  • Loading branch information
fredericd authored and ranginui committed Jun 9, 2011
1 parent e071651 commit 2281350
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions misc/translator/tmpl_process3.pl
Expand Up @@ -274,6 +274,21 @@ (;$)
# $charset_in = $candidate;
# }
# }

# BUG6464: check consistency of PO messages
# - count number of '%s' in msgid and msgstr
for my $msg ( values %$href ) {
my $id_count = split(/%s/, $msg->{msgid}) - 1;
my $str_count = split(/%s/, $msg->{msgstr}) - 1;
next if $id_count == $str_count ||
$msg->{msgstr} eq '""' ||
grep { /fuzzy/ } @{$msg->{_flags}};
warn_normal
"unconsistent %s count: ($id_count/$str_count):\n" .
" line: " . $msg->{loaded_line_number} . "\n" .
" msgid: " . $msg->{msgid} . "\n" .
" msgstr: " . $msg->{msgstr} . "\n", undef;
}
}

# set our charset in to UTF-8
Expand Down

0 comments on commit 2281350

Please sign in to comment.