Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some untranslatable characters from msgids #307

Merged
8 commits merged into from Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@
^MYMETA\.
#!end included /usr/share/perl/5.20/ExtUtils/MANIFEST.SKIP

# Development mode aid for File::ShareDir
^lib/auto/share/dist/Zonemaster-CLI
67 changes: 50 additions & 17 deletions lib/Zonemaster/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,28 @@ sub run {
Zonemaster::Engine->preload_cache( $self->restore );
}

my %field_width = (
seconds => 7,
level => 9,
module => 12,
testcase => 14
);
my %header_names = ();
my %remaining_space = ();
if ( $translator ) {
%header_names = (
seconds => __( 'Seconds' ),
level => __( 'Level' ),
module => __( 'Module' ),
testcase => __( 'Testcase' ),
message => __( 'Message' )
);
foreach ( keys %header_names ) {
$field_width{$_} = _max( $field_width{$_}, length( decode( 'UTF-8', $header_names{$_} ) ) );
$remaining_space{$_} = $field_width{$_} - length( decode( 'UTF-8', $header_names{$_} ) );
}
}

# Callback defined here so it closes over the setup above.
Zonemaster::Engine->logger->callback(
sub {
Expand All @@ -397,19 +419,19 @@ sub run {
if ( $translator ) {
my $header = q{};
if ( $self->time ) {
$header .= sprintf "%7.2f ", $entry->timestamp;
$header .= sprintf "%*.2f ", ${field_width{seconds}}, $entry->timestamp;
}

if ( $self->show_level ) {
$header .= sprintf "%-9s ", translate_severity( $entry->level );
$header .= sprintf "%-*s ", ${field_width{level}}, translate_severity( $entry->level );
}

if ( $self->show_module ) {
$header .= sprintf "%-12s ", $entry->module;
$header .= sprintf "%-*s ", ${field_width{module}}, $entry->module;
}

if ( $self->show_testcase ) {
$header .= sprintf "%-14s ", $entry->testcase;
$header .= sprintf "%-*s ", ${field_width{testcase}}, $entry->testcase;
}

print $header;
Expand Down Expand Up @@ -444,12 +466,12 @@ sub run {
# Don't do anything
}
else {
my $prefix = sprintf "%7.2f %-9s ", $entry->timestamp, $entry->level;
my $prefix = sprintf "%*.2f %-*s ", ${field_width{seconds}}, $entry->timestamp, ${field_width{level}}, $entry->level;
if ( $self->show_module ) {
$prefix .= sprintf "%-12s ", $entry->module;
$prefix .= sprintf "%-*s ", ${field_width{module}}, $entry->module;
}
if ( $self->show_testcase ) {
$prefix .= sprintf "%-14s ", $entry->testcase;
$prefix .= sprintf "%-*s ", ${field_width{testcase}}, $entry->testcase;
}
$prefix .= $entry->tag;

Expand Down Expand Up @@ -512,33 +534,37 @@ sub run {
}

if ( $translator ) {
my $header = q{};

if ( $self->time ) {
print __( 'Seconds ' );
$header .= sprintf "%s%s ", $header_names{seconds}, " " x $remaining_space{seconds};
}
if ( $self->show_level ) {
print __( 'Level ' );
$header .= sprintf "%s%s ", $header_names{level}, " " x $remaining_space{level};
}
if ( $self->show_module ) {
print __( 'Module ' );
$header .= sprintf "%s%s ", $header_names{module}, " " x $remaining_space{module};
}
if ( $self->show_testcase ) {
print __( 'Testcase ' );
$header .= sprintf "%s%s ", $header_names{testcase}, " " x $remaining_space{testcase};
}
say __( 'Message' );
$header .= sprintf "%s\n", $header_names{message};

if ( $self->time ) {
print __( '======= ' );
$header .= sprintf "%s ", "=" x $field_width{seconds};
}
if ( $self->show_level ) {
print __( '========= ' );
$header .= sprintf "%s ", "=" x $field_width{level};
}
if ( $self->show_module ) {
print __( '============ ' );
$header .= sprintf "%s ", "=" x $field_width{module};
}
if ( $self->show_testcase ) {
print __( '============== ' );
$header .= sprintf "%s ", "=" x $field_width{testcase};
}
say __( '=======' );
$header .= sprintf "%s\n", "=" x $field_width{message};

print $header;
} ## end if ( $translator )

# Actually run tests!
Expand Down Expand Up @@ -779,6 +805,13 @@ sub translate_severity {
}
}

sub _max {
my ( $a, $b ) = @_;
$a //= 0;
$b //= 0;
return ( $a > $b ? $a : $b ) ;
}

1;

__END__
Expand Down
1 change: 1 addition & 0 deletions lib/auto/share/dist/Zonemaster-CLI
31 changes: 8 additions & 23 deletions share/da.po
Original file line number Diff line number Diff line change
Expand Up @@ -188,36 +188,21 @@ msgstr "Domænenavn, der skal testes, skal angives.\n"
msgid "The domain name contains consecutive dots.\n"
msgstr "Domænenavnet indeholder flere dots (.) efter hinanden.\n"

msgid "Seconds "
msgstr "Sekunder "
msgid "Seconds"
msgstr "Sekunder"

msgid "Level "
msgstr "Niveau "
msgid "Level"
msgstr "Niveau"

msgid "Module "
msgstr "Modul "
msgid "Module"
msgstr "Modul"

msgid "Testcase "
msgstr "Testcase "
msgid "Testcase"
msgstr "Testcase"

msgid "Message"
msgstr "Besked"

msgid "======= "
msgstr "======= "

msgid "========= "
msgstr "========= "

msgid "============ "
msgstr "============ "

msgid "============== "
msgstr "============== "

msgid "======="
msgstr "======="

msgid "Looks OK."
msgstr "Ser OK ud."

Expand Down
52 changes: 8 additions & 44 deletions share/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -206,36 +206,21 @@ msgstr "Debe indicar el nombre de un dominio a probar.\n"
msgid "The domain name contains consecutive dots.\n"
msgstr "El nombre de dominio contiene puntos consecutivos.\n"

msgid "Seconds "
msgstr "Segundos "
msgid "Seconds"
msgstr "Segundos"

msgid "Level "
msgstr "Nivel "
msgid "Level"
msgstr "Nivel"

msgid "Module "
msgstr "Módulo "
msgid "Module"
msgstr "Módulo"

msgid "Testcase "
msgstr "Caso de prueba "
msgid "Testcase"
msgstr "Caso de prueba"

msgid "Message"
msgstr "Mensaje"

msgid "======= "
msgstr "======= "

msgid "========= "
msgstr "========= "

msgid "============ "
msgstr "============ "

msgid "============== "
msgstr "============== "

msgid "======="
msgstr "======="

msgid "Looks OK."
msgstr "Se ve bien."

Expand Down Expand Up @@ -284,24 +269,3 @@ msgstr "ERROR"

msgid "CRITICAL"
msgstr "CRÍTICO"

#~ msgid "The minimum severity level to display"
#~ msgstr "El nivel mínimo de gravedad que despliega"

#~ msgid "Name of configuration file to load."
#~ msgstr "Nombre del archivo de configuración a cargar."

#~ msgid "Loading configuration from {path}."
#~ msgstr "Cargando configuración desde {path}."

#~ msgid "Print the effective configuration used in JSON format, then exit."
#~ msgstr ""
#~ "Despliega la configuración definitiva usada en formato JSON, luego "
#~ "termina."

#~ msgid ""
#~ "Local IP address that the test engine should try to send its requests "
#~ "from."
#~ msgstr ""
#~ "Dirección IP local que debería usar el motor de pruebas como origen de "
#~ "sus solicitudes."
31 changes: 8 additions & 23 deletions share/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -203,36 +203,21 @@ msgstr "Testattavan verkkoalueen nimi on annettava.\n"
msgid "The domain name contains consecutive dots.\n"
msgstr "Verkkotunnus sisältää peräkkäisiä pisteitä.\n"

msgid "Seconds "
msgstr "Sekuntia "
msgid "Seconds"
msgstr "Sekuntia"

msgid "Level "
msgstr "Taso "
msgid "Level"
msgstr "Taso"

msgid "Module "
msgstr "Moduuli "
msgid "Module"
msgstr "Moduuli"

msgid "Testcase "
msgstr "Testitapaus "
msgid "Testcase"
msgstr "Testitapaus"

msgid "Message"
msgstr "Viesti"

msgid "======= "
msgstr "======= "

msgid "========= "
msgstr "========= "

msgid "============ "
msgstr "============ "

msgid "============== "
msgstr "============== "

msgid "======="
msgstr "======="

msgid "Looks OK."
msgstr "Näyttää olevan OK."

Expand Down
31 changes: 8 additions & 23 deletions share/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -218,36 +218,21 @@ msgstr "Il est nécessaire d'indiquer un nom de domaine pour lancer le test.\n"
msgid "The domain name contains consecutive dots.\n"
msgstr "Le nom de domaine contient des points consécutifs.\n"

msgid "Seconds "
msgstr "Durée "
msgid "Seconds"
msgstr "Durée"

msgid "Level "
msgstr "Niveau "
msgid "Level"
msgstr "Niveau"

msgid "Module "
msgstr "Module "
msgid "Module"
msgstr "Module"

msgid "Testcase "
msgstr "Plan de test "
msgid "Testcase"
msgstr "Plan de test"

msgid "Message"
msgstr "Message"

msgid "======= "
msgstr "======= "

msgid "========= "
msgstr "========= "

msgid "============ "
msgstr "============ "

msgid "============== "
msgstr "============== "

msgid "======="
msgstr "======="

msgid "Looks OK."
msgstr "Le résultat semble concluant."

Expand Down
31 changes: 8 additions & 23 deletions share/nb.po
Original file line number Diff line number Diff line change
Expand Up @@ -190,36 +190,21 @@ msgstr "Må angi navnet på domenet som skal testes.\n"
msgid "The domain name contains consecutive dots.\n"
msgstr "Domenenavnet inneholder flere punkter på rad.\n"

msgid "Seconds "
msgstr "Sekunder "
msgid "Seconds"
msgstr "Sekunder"

msgid "Level "
msgstr "Nivå "
msgid "Level"
msgstr "Nivå"

msgid "Module "
msgstr "Modul "
msgid "Module"
msgstr "Modul"

msgid "Testcase "
msgstr "Test "
msgid "Testcase"
msgstr "Test"

msgid "Message"
msgstr "Melding"

msgid "======= "
msgstr "======== "

msgid "========= "
msgstr "========= "

msgid "============ "
msgstr "============ "

msgid "============== "
msgstr "============== "

msgid "======="
msgstr "======="

msgid "Looks OK."
msgstr "Ser OK ut."

Expand Down
Loading