summaryrefslogtreecommitdiffstats
path: root/gurpmi.pm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-02-01 13:39:21 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-02-01 13:39:21 +0000
commit8265e240c71f71e21067bea8fd4ee3b24136ffd4 (patch)
tree4be00ecff17cfd95b2958ce0dc7f05884800292b /gurpmi.pm
parent42fafbd9102715ce9ea7d43d7fd60a8e9146a96b (diff)
downloadurpmi-8265e240c71f71e21067bea8fd4ee3b24136ffd4.tar
urpmi-8265e240c71f71e21067bea8fd4ee3b24136ffd4.tar.gz
urpmi-8265e240c71f71e21067bea8fd4ee3b24136ffd4.tar.bz2
urpmi-8265e240c71f71e21067bea8fd4ee3b24136ffd4.tar.xz
urpmi-8265e240c71f71e21067bea8fd4ee3b24136ffd4.zip
Convert strings to UTF-8 before display in gurpmi and gurpmi2.
(bug 13296)
Diffstat (limited to 'gurpmi.pm')
-rw-r--r--gurpmi.pm27
1 files changed, 17 insertions, 10 deletions
diff --git a/gurpmi.pm b/gurpmi.pm
index af18242b..06a6aa6d 100644
--- a/gurpmi.pm
+++ b/gurpmi.pm
@@ -5,14 +5,12 @@ package gurpmi;
#- changing only LC_COLLATE will have no effect.
use POSIX qw(setlocale LC_ALL LC_COLLATE);
use locale;
-BEGIN {
- my $collation_locale = $ENV{LC_ALL};
- if ($collation_locale) {
- $collation_locale =~ /UTF-8/ or setlocale(LC_ALL, "$collation_locale.UTF-8");
- } else {
- $collation_locale = setlocale(LC_COLLATE);
- $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8");
- }
+my $collation_locale = $ENV{LC_ALL};
+if ($collation_locale) {
+ $collation_locale =~ /UTF-8/ or setlocale(LC_ALL, "$collation_locale.UTF-8");
+} else {
+ $collation_locale = setlocale(LC_COLLATE);
+ $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8");
}
use urpm;
@@ -20,7 +18,7 @@ use strict;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw(fatal but quit add_button_box new_label);
+our @EXPORT = qw(fatal but quit add_button_box new_label N);
sub usage () {
print STDERR <<USAGE;
@@ -34,7 +32,7 @@ USAGE
}
#- fatal gurpmi initialisation error (*not* fatal urpmi errors)
-sub fatal { print STDERR "$_[0]\n"; exit 1 }
+sub fatal { my $s = $_[0]; print STDERR "$s\n"; exit 1 }
#- Parse command line
#- puts options in %gurpmi::options
@@ -80,4 +78,13 @@ sub new_label {
}
}
+sub N {
+ my ($format, @params) = @_;
+ my $r = sprintf(
+ eval { Locale::gettext::gettext($format || '') } || $format,
+ @params,
+ );
+ Locale::gettext::iconv($r, undef, "UTF-8");
+}
+
1;