From d52e93215c1699058eaaca11c3210bfe402c1a32 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Mon, 9 Dec 2019 20:41:45 -0300 Subject: [PATCH] Bug 18688: Warnings about UTF-8 charset when creating a new language This patch removes some warnings when creating new languages, those related with uft8 and two not related. Tipical messages are: >Warning: Can't determine original templates' charset, defaulting to UTF-8 >Warning: Charset Out defaulting to UTF-8 >... >Removing empty file /../xx-YY-marc-NORMARC.po >I UTF-8 O UTF-8 at /../kohaclone/misc/translator/tmpl_process3.pl line 365. >Use of uninitialized value $pref_name in concatenation (.) or string at /.../misc/translator/LangInstaller.pm line 197. >Created /../misc/translator/po/xx-YY-messages.po. First four are 'normal' messages The fifth one correspond to an unquoted preference string The sixth one is a normal output message from msgint command We will hide them unless verbose '-v' option is selected, and fix the error. To test: 1) Go to misc/translator 2) Create new language files $ perl translate create xx-YY 3) Check warnings and messages 4) Apply the patch 5) Remove created files, and create them again Ther must be no messages 6) Repeat 5) with verbose option '-v', check old messages 7) BONUS: without the patch update a language, for example de-DE: $ perl translate update de-DE Note (git status) a new file, po/de-DE-messages.po~ This is a backup file from msgmerge command With the patch this backup is removed. Signed-off-by: Jonathan Druart --- .../prog/en/modules/admin/preferences/enhanced_content.pref | 2 +- misc/translator/LangInstaller.pm | 5 +++-- misc/translator/tmpl_process3.pl | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref index 8f32cadb2d..2d4c1dfb10 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref @@ -10,7 +10,7 @@ Enhanced Content: yes: "Show" - cover images in OPAC results and detail listing from Swedish retailer Adlibris. - - - Use base URL: + - "Use base URL: " - pref: AdlibrisCoversURL class: url default: "http://www.adlibris.com/se/organisationer/showimagesafe.aspx" diff --git a/misc/translator/LangInstaller.pm b/misc/translator/LangInstaller.pm index 47bddd6f36..3da23a84d8 100644 --- a/misc/translator/LangInstaller.pm +++ b/misc/translator/LangInstaller.pm @@ -493,7 +493,8 @@ sub create_messages { say "Create messages ($self->{lang})" if $self->{verbose}; my $locale = $self->locale_name(); - system "$self->{msginit} -i $pot -o $po -l $locale --no-translator"; + system "$self->{msginit} -i $pot -o $po -l $locale --no-translator 2> /dev/null"; + warn "Problems creating $pot ".$? if ( $? == -1 ); # If msginit failed to correctly set Plural-Forms, set a default one system "$self->{sed} --in-place $po " @@ -512,7 +513,7 @@ sub update_messages { if ( -f $po ) { say "Update messages ($self->{lang})" if $self->{verbose}; - system "$self->{msgmerge} --quiet -U $po $pot"; + system "$self->{msgmerge} --backup=off --quiet -U $po $pot"; } else { $self->create_messages(); } diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index 58c12b9049..68c58f0cc6 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -337,12 +337,12 @@ if (defined $href) { # set our charset in to UTF-8 if (!defined $charset_in) { $charset_in = TmplTokenizer::charset_canon 'UTF-8'; - warn "Warning: Can't determine original templates' charset, defaulting to $charset_in\n"; + warn "Warning: Can't determine original templates' charset, defaulting to $charset_in\n" unless ( $quiet ); } # set our charset out to UTF-8 if (!defined $charset_out) { $charset_out = TmplTokenizer::charset_canon 'UTF-8'; - warn "Warning: Charset Out defaulting to $charset_out\n"; + warn "Warning: Charset Out defaulting to $charset_out\n" unless ( $quiet ); } my $xgettext = './xgettext.pl'; # actual text extractor script my $st; @@ -350,7 +350,7 @@ my $st; if ($action eq 'create') { # updates the list. As the list is empty, every entry will be added if (!-s $str_file) { - warn "Removing empty file $str_file\n"; + warn "Removing empty file $str_file\n" unless ( $quiet ); unlink $str_file || die "$str_file: $!\n"; } die "$str_file: Output file already exists\n" if -f $str_file; @@ -362,7 +362,7 @@ if ($action eq 'create') { print $tmph1 "$input\n"; } close $tmph1; - warn "I $charset_in O $charset_out"; + warn "I $charset_in O $charset_out" unless ( $quiet ); # Generate the specified po file ($str_file) $st = system ($xgettext, '-s', '-f', $tmpfile1, '-o', $tmpfile2, (defined $charset_in? ('-I', $charset_in): ()), -- 2.11.0