Bug 15395: Do not process template files that do not use i18n.inc
authorJulian Maurice <julian.maurice@biblibre.com>
Thu, 25 Oct 2018 13:04:46 +0000 (15:04 +0200)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 8 Nov 2018 15:55:52 +0000 (15:55 +0000)
It should make the string extraction process a little faster

For the record, I timed some parts of the process to see why it was so
slow, and without surprises the most time-consuming task is the Perl
code analysis by PPI with an average time of 50ms by "template block" on
my machine.
Multiply that by the number of template blocks (approximatively 900),
that gives us 45 seconds just for this task.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

misc/translator/LangInstaller.pm

index deff3ab..b8a6ee6 100644 (file)
@@ -527,6 +527,10 @@ sub extract_messages_from_templates {
     foreach my $file (@files) {
         say "Extract messages from $file" if $self->{verbose};
         my $template = read_file("$intranetdir/$file");
+
+        # No need to process a file that doesn't use the i18n.inc file.
+        next unless $template =~ /i18n\.inc/;
+
         my $data = $parser->parse($template);
         unless ($data) {
             warn "Error at $file : " . $parser->error();