diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2021-06-06 00:40:59 +0200 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2021-10-31 05:38:17 +0100 |
commit | 64b20ffd4cf24ed769b9f3fd3683fe3f07426232 (patch) | |
tree | 99c094d661311424259f95f7c87adf83c5addceb /urpm/msg.pm | |
parent | 87b5ad27901b44b6846413398b5e175a7b00b3a7 (diff) | |
download | urpmi-64b20ffd4cf24ed769b9f3fd3683fe3f07426232.tar urpmi-64b20ffd4cf24ed769b9f3fd3683fe3f07426232.tar.gz urpmi-64b20ffd4cf24ed769b9f3fd3683fe3f07426232.tar.bz2 urpmi-64b20ffd4cf24ed769b9f3fd3683fe3f07426232.tar.xz urpmi-64b20ffd4cf24ed769b9f3fd3683fe3f07426232.zip |
Podify more
Diffstat (limited to 'urpm/msg.pm')
-rw-r--r-- | urpm/msg.pm | 88 |
1 files changed, 78 insertions, 10 deletions
diff --git a/urpm/msg.pm b/urpm/msg.pm index a79e59b8..6efe681c 100644 --- a/urpm/msg.pm +++ b/urpm/msg.pm @@ -7,6 +7,20 @@ use Exporter; use URPM; use urpm::util 'append_to_file'; +=head1 NAME + +urpm::msg - routines to prompt messages from the urpm* tools + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=over + +=cut + my $encoding; BEGIN { eval { require encoding; $encoding = encoding::_get_locale_encoding() }; @@ -40,6 +54,13 @@ sub from_locale_encoding { } || $s; } + +=item translate($s, $o_plural, $o_nb) + +Actually translate a string using gettext. + +=cut + sub translate { my ($s, $o_plural, $o_nb) = @_; my $res; @@ -60,15 +81,36 @@ sub translate { } } +=item P($s_singular, $s_plural, $nb, @para) + +Like N(), translate a string but with different singular/plural strings according to $nb + +=cut + sub P { my ($s_singular, $s_plural, $nb, @para) = @_; sprintf(translate($s_singular, $s_plural, $nb), @para); } +=item N($format, @params) + +Translate the $format string (a la printf using @params) + +=cut + sub N { my ($format, @params) = @_; sprintf(translate($format), @params); } + +=item N_($string) + +Unlike N(), it doesn't actually translate $string but serves to tag a string as translatable for extracting into pod catalog. + +The string will actually be translated later using translate(). + +=cut + sub N_ { $_[0] } my $noexpr = N("Nn"); @@ -88,9 +130,20 @@ eval { END { defined &closelog and closelog() } }; +=item sys_log(...) + +Log through syslog if Sys::Syslog is installed. + +=cut + sub sys_log { defined &syslog and eval { syslog("info", @_) } } -#- writes only to logfile, not to screen +=item bug_log(...) + +Writes only to logfile, not to screen + +=cut + sub bug_log { append_to_file($::logfile, @_) if $::logfile; } @@ -131,6 +184,13 @@ sub _message_input { return $input; } + +=item toMb($nb) + +Convert a number of bytes into Mb + +=cut + sub toMb { my $nb = $_[0] / 1024 / 1024; int $nb + 0.5; @@ -185,7 +245,22 @@ sub _format_line_selected_packages { map { sprintf($format_line_format, @$_) } @l); } -# duplicated from svn+ssh://svn.mandriva.com/svn/soft/drakx/trunk/perl-install/common.pm + +=item formatXiB($number [, $o_newbase]) + +Returns a nicely human size. eg: + + 2097152 => "2MB" + +The optional parameter enables to provide the unit size (default is one). +eg for a 2000 512 sized sectors: + + formatXiB(2000, 512) + +Duplicated from L<common> (drakx/perl-install/common.pm) + +=cut + sub formatXiB { my ($newnb, $o_newbase) = @_; my $newbase = $o_newbase || 1; @@ -211,14 +286,7 @@ sub localtime2changelog { scalar(localtime($_[0])) =~ /(.*) \S+ (\d{4})$/ && "$1 1; - -=head1 NAME - -urpm::msg - routines to prompt messages from the urpm* tools - -=head1 SYNOPSIS - -=head1 DESCRIPTION +=back =head1 COPYRIGHT |