summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gurpmi4
-rw-r--r--gurpmi.pm27
-rwxr-xr-xgurpmi25
3 files changed, 21 insertions, 15 deletions
diff --git a/gurpmi b/gurpmi
index 96c1c25d..0e10229a 100644
--- a/gurpmi
+++ b/gurpmi
@@ -10,11 +10,11 @@ BEGIN { #- set up a safe path and environment
delete @ENV{qw(ENV BASH_ENV IFS CDPATH)};
}
-use gurpmi;
-use urpm::msg qw(N);
use Gtk2;
use MDK::Common::Func qw(partition);
+use gurpmi;
+
#- globals
my ($srpms, $rpms);
my ($mainw, $mainbox);
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;
diff --git a/gurpmi2 b/gurpmi2
index 2af0e23d..aab331d4 100755
--- a/gurpmi2
+++ b/gurpmi2
@@ -11,7 +11,6 @@ BEGIN { #- set up a safe path and environment
}
use gurpmi;
-use urpm::msg qw(N);
use Gtk2;
#- GUI globals
@@ -86,12 +85,12 @@ Gtk2->main;
sub configure_urpm {
my $urpm = new urpm;
$urpm->{fatal} = sub {
- Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'error', 'ok', $_[1])->run;
+ Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'error', 'ok', Locale::gettext::iconv($_[1], undef, 'UTF-8'))->run;
quit;
exit $_[0];
};
$urpm->{error} = sub {
- my $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', $_[0]);
+ my $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', Locale::gettext::iconv($_[0], undef, 'UTF-8'));
$w->run;
$w->destroy;
};