Bug 24262: (follow-up) admit null values on labels
authorBernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Thu, 5 Mar 2020 13:23:53 +0000 (10:23 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 9 Mar 2020 13:54:24 +0000 (13:54 +0000)
This patch adds handling of null values on translatable
labels.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

misc/translator/LangInstaller.pm

index ef5dd3d..7b5e236 100644 (file)
@@ -523,7 +523,7 @@ sub get_po_from_target {
                                 }
                             }
                         } else {
-                            if ( length($row->{$field}) > 1                         # discard small strings
+                            if ( defined $row->{$field} and length($row->{$field}) > 1                         # discard null values and small strings
                                  and not $po->{ $row->{$field} } ) {
                                 my $msg = new Locale::PO(
                                             -msgid => $row->{$field}, -msgstr => '',
@@ -653,6 +653,7 @@ sub translate_yaml {
                         }
                     }
                 } else {
+                    next unless defined $row->{$field};                                 # next if null value
                     my $po = $po_ref->{"\"$row->{$field}\""};                           # quoted key
                     if ( $po  and not defined( $po->fuzzy() )                           # not fuzzy
                               and length( $po->msgid() ) > 2                            # not empty msgid