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 <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Bernardo Gonzalez Kriegel 2019-12-09 20:41:45 -03:00 committed by Martin Renvoize
parent 61ca2359f2
commit 6e3e8fef6a
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
3 changed files with 8 additions and 7 deletions

View file

@ -10,7 +10,7 @@ Enhanced Content:
yes: "Show"
- cover images in OPAC results and detail listing from Swedish retailer <a href="https://www.adlibris.com/se">Adlibris</a>.
-
- Use base URL:
- "Use base URL: "
- pref: AdlibrisCoversURL
class: url
default: "http://www.adlibris.com/se/organisationer/showimagesafe.aspx"

View file

@ -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();
}

View file

@ -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): ()),