summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-07-23 18:48:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-07-23 18:48:32 +0000
commite58875f801fa0703cef9138df2ed456b34462969 (patch)
treea19cb45c9223771542847b0bb6de18c16ac4f5fb /perl-install
parentdb1ceba674784dfd8ffaacbff6446e6a6102b448 (diff)
downloaddrakx-e58875f801fa0703cef9138df2ed456b34462969.tar
drakx-e58875f801fa0703cef9138df2ed456b34462969.tar.gz
drakx-e58875f801fa0703cef9138df2ed456b34462969.tar.bz2
drakx-e58875f801fa0703cef9138df2ed456b34462969.tar.xz
drakx-e58875f801fa0703cef9138df2ed456b34462969.zip
do not use the po's directly. Use mo's through gettext
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/Makefile6
-rw-r--r--perl-install/Makefile.drakxtools17
-rw-r--r--perl-install/c/stuff.xs.pm17
-rw-r--r--perl-install/common.pm19
-rw-r--r--perl-install/lang.pm74
-rw-r--r--perl-install/share/po/.cvsignore1
-rw-r--r--perl-install/share/po/Makefile33
-rw-r--r--perl-install/standalone.pm5
8 files changed, 84 insertions, 88 deletions
diff --git a/perl-install/Makefile b/perl-install/Makefile
index 6516cf674..9ce41430e 100644
--- a/perl-install/Makefile
+++ b/perl-install/Makefile
@@ -16,7 +16,7 @@ tar-drakxtools: clean
$(MAKE) -C ../tools clean
cd .. ; rm -rf drakxtools ; cp -af perl-install drakxtools ; cp -af tools/ddcprobe tools/serial_probe drakxtools
cd ../drakxtools ; perl -pi -e 's/^C_RPM.*/C_RPM=0/; s/^C_DRAKX.*/C_DRAKX=0/' c/Makefile
- cd ../drakxtools ; rm -rf install* pkgs.pm ftp.pm t.pm */CVS ; mv Makefile.drakxtools Makefile ; mv -f standalone/* .
+ cd ../drakxtools ; rm -rf install* pkgs.pm help.pm ftp.pm t.pm */CVS ; mv Makefile.drakxtools Makefile ; mv -f standalone/* .
cd .. ; tar cfj drakxtools.tar.bz2 --exclude CVS $(patsubst %,drakxtools/%,Makefile Makefile.config Newt c ddcprobe serial_probe share/po sbus_probing resize_fat share/diskdrake.rc share/wizard.rc $(STANDALONEPMS) icons pixmaps *.pm)
cd .. ; rm -rf drakxtools
@@ -44,8 +44,6 @@ install_pms: $(DIRS)
# perl -pe 's/#-.*//; $$_ = "\n" if (/^=head/ .. /^=cut/) || /use (diagnostics)/' $$i > $(DESTREP4PMS)/$$i; \
cp share/*.rc $(DESTREP4PMS)
- install -d $(DESTREP4PMS)/po
- cp -f share/po/*.po* $(DESTREP4PMS)/po ||:
chmod a+x $(DESTREP4PMS)/install2
chmod a+x $(DESTREP4PMS)/commands
chmod a+x $(DESTREP4PMS)/standalone/*
@@ -141,6 +139,8 @@ endif
for i in ../all.modules/modules.cz*; do cp -f $$i $(DEST)/lib/; done
+ $(MAKE) -C share/po install NAME=libDrakX LOCALEDIR=$(DEST)/usr/share/locale_special
+
# echo -e '#!/bin/sh\n\nexec "/usr/bin/sh"' > $(DEST)/usr/bin/runinstall2
# chmod a+x $(DEST)/usr/bin/runinstall2
diff --git a/perl-install/Makefile.drakxtools b/perl-install/Makefile.drakxtools
index 7395064d4..1128dedb5 100644
--- a/perl-install/Makefile.drakxtools
+++ b/perl-install/Makefile.drakxtools
@@ -1,15 +1,17 @@
include Makefile.config
DIRS = ddcprobe serial_probe share/po Newt c resize_fat
+NAME = libDrakX
PREFIX =
-SBINDEST = $(PREFIX)/usr/sbin
-ETCDEST = $(PREFIX)/etc/gtk
+LIBDIR = $(PREFIX)/usr/lib
DATADIR = $(PREFIX)/usr/share
BINDEST = $(PREFIX)/usr/bin
-LIBDEST = $(PREFIX)/usr/lib/libDrakX
+SBINDEST = $(PREFIX)/usr/sbin
+ETCDEST = $(PREFIX)/etc/gtk
BINX11DEST = $(PREFIX)/usr/X11R6/bin
LIBX11DEST = $(PREFIX)/usr/X11R6/lib/X11
-PIXDIR = $(PREFIX)/usr/share/libDrakX/pixmaps
+LIBDEST = $(LIBDIR)/$(NAME)
+PIXDIR = $(DATADIR)/$(NAME)/pixmaps
.PHONY: $(DIRS)
all: $(DIRS)
@@ -21,7 +23,7 @@ $(DIRS):
$(MAKE) -C $@
install:
- install -d $(BINDEST) $(ETCDEST) $(SBINDEST) $(DATADIR) $(LIBDEST) $(BINX11DEST) $(LIBX11DEST) $(PIXDIR) $(LIBDEST)/po $(DIRS:%=$(LIBDEST)/%)
+ install -d $(BINDEST) $(ETCDEST) $(SBINDEST) $(DATADIR) $(LIBDEST) $(BINX11DEST) $(LIBX11DEST) $(PIXDIR) $(DIRS:%=$(LIBDEST)/%)
install -d $(LIBDEST)/sbus_probing
install $(STANDALONEPMS) $(SBINDEST)
install -s ddcprobe/ddcxinfos serial_probe/serial_probe $(SBINDEST)
@@ -31,13 +33,12 @@ install:
install -m 644 pixmaps/* $(PIXDIR)
install -m 644 share/diskdrake.rc $(ETCDEST)
install -m 644 share/wizard.rc $(ETCDEST)
- install -m 644 share/po/*.po $(LIBDEST)/po
install -m 644 $(patsubst %,Newt/%.pm,Newt) $(LIBDEST)/Newt
install -m 644 $(patsubst %,c/%.pm,stuff) $(LIBDEST)/c
install -m 644 $(patsubst %,sbus_probing/%.pm,main) $(LIBDEST)/sbus_probing
install -m 644 $(patsubst %,resize_fat/%.pm,main any boot_sector c_rewritten dir_entry directory fat info_sector io) $(LIBDEST)/resize_fat
find $(LIBDEST) -name "*.pm" | xargs perl -pi -e '$$_ = "\n" if /\s*use\s+(diagnostics|vars|strict)/'
+ $(MAKE) -C share/po install DATADIR=$(DATADIR) NAME=$(NAME)
+
cp -rf auto icons $(LIBDEST)
- bzip2 -9 $(LIBDEST)/po/*.po
- find $(LIBDEST) -name "*.so" | xargs strip
diff --git a/perl-install/c/stuff.xs.pm b/perl-install/c/stuff.xs.pm
index cd250e4a3..235e929c3 100644
--- a/perl-install/c/stuff.xs.pm
+++ b/perl-install/c/stuff.xs.pm
@@ -35,6 +35,7 @@ print '
#include <X11/Xlib.h>
#include <X11/extensions/xf86misc.h>
+#include <libintl.h>
#include <term.h>
#undef max_colors
@@ -149,6 +150,22 @@ setMouseLive(display, type, emulate3buttons)
';
print '
+
+void
+setlocale()
+ CODE:
+ setlocale(LC_ALL, "");
+
+char *
+bindtextdomain(domainname, dirname)
+ char * domainname
+ char * dirname
+
+char *
+dgettext(domainname, msgid)
+ char * domainname
+ char * msgid
+
int
KTYP(x)
int x
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 73c1d9adb..0eed816b1 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -53,9 +53,7 @@ sub fold_left(&@) {
sub _ {
my $s = shift @_; my $t = translate($s);
- $t && ref $t or return sprintf $t, @_;
- my ($T, @p) = @$t;
- sprintf $T, @_[@p];
+ sprintf $t, @_;
}
#-delete $main::{'_'};
sub __ { $_[0] }
@@ -368,20 +366,7 @@ sub list_skels {
sub translate {
my ($s) = @_;
- if (ref($s) eq 'ARRAY') {
- $s = $s->[0] == 1 ? "singular\0$s->[1]" : "plural\0$s->[2]";
- }
- my ($lang) = $ENV{LANGUAGE} || $ENV{LC_MESSAGES} || $ENV{LC_ALL} || $ENV{LANG} || 'en';
-
- require lang;
- foreach (split ':', $lang) {
- lang::load_po($_) unless defined $po::I18N::{$_};
- if (%{$po::I18N::{$_}}) {
- return if $s eq '_I18N_';
- return ${$po::I18N::{$_}}{$s} || $s
- }
- }
- $s;
+ c::dgettext('libDrakX', $s);
}
sub untranslate($@) {
diff --git a/perl-install/lang.pm b/perl-install/lang.pm
index 77dfb5f5b..5f316aaac 100644
--- a/perl-install/lang.pm
+++ b/perl-install/lang.pm
@@ -318,7 +318,6 @@ sub set {
$ENV{LC_TIME} = "C";
$ENV{LC_COLLATE} = "C";
$ENV{LC_MONETARY} = "C";
- $ENV{LC_MESSAGES} = "C";
$ENV{LC_PAPER} = "C";
$ENV{LC_NAME} = "C";
$ENV{LC_ADDRESS} = "C";
@@ -327,9 +326,11 @@ sub set {
$ENV{LC_IDENTIFICATION} = "C";
$ENV{LC_CTYPE} = $lang;
+ $ENV{LC_MESSAGES} = $languages{$lang}[2];
$ENV{LANG} = $languages{$lang}[2];
$ENV{LANGUAGE} = $languages{$lang}[3];
+ load_mo($ENV{LANG});
} else {
# stick with the default (English) */
delete $ENV{LANG};
@@ -411,62 +412,33 @@ sub write {
setVarsInSh("$prefix/etc/sysconfig/i18n", $h);
}
-sub load_po {
+sub load_mo {
my ($lang) = @_;
- my ($s, $from, $to, $state, $fuzzy);
-
- $s .= "package po::I18N;\n";
- $s .= "no strict;\n";
- $s .= "\%{'$lang'} = (";
-
- my $f; -e ($f = "$_/po/$lang.po") and last foreach @INC;
-
- my $F;
- unless ($f && -e $f) {
- -e ($f = "$_/po/$lang.po.bz2") and last foreach @INC;
- if (-e $f) {
- open $F, "$ENV{LD_LOADER} bzip2 -dc $f 2>/dev/null |";
- } elsif ($::isInstall) {
- require install_any;
- $F = install_any::getFile("Mandrake/mdkinst/usr/bin/perl-install/po/$lang.po");
- }
- } else {
- open $F, $f; #- not returning here help avoiding reading the same multiple times.
- }
- local $_;
- while (<$F>) {
- /^msgstr/ and $state = 'msgstr';
- /^msgid/ && !$fuzzy and $state = 'msgid';
- s/@/\\@/g;
-
- if (/^(#|$)/ && $state ne 'between') {
- $state = 'between';
- $to = c::iconv($to, $lang::charset, c::standard_charset());
- if (my @l = $to =~ /%(\d+)\$/g) {
- $to =~ s/%(\d+)\$/%/g;
- $to = qq([ "$to", ) . join(",", map { $_ - 1 } @l) . " ],";
- } else {
- $to = qq("$to");
- }
- if ($from) {
- $s .= qq("$from" => $to,\n);
- } elsif ($to =~ /charset=([\w-]+)/) {
- $lang::charset = $1;
- }
- $from = $to = '';
- }
- $to .= (/"(.*)"/)[0] if $state eq 'msgstr';
- $from .= (/"(.*)"/)[0] if $state eq 'msgid';
+ my ($localedir, $suffix) = ('/usr/share/locale', 'LC_MESSAGES/libDrakX.mo');
+ $localedir .= "_special" if $::isInstall;
- $fuzzy = /^#, fuzzy/;
+ $lang ||= $ENV{LANGUAGE} || $ENV{LC_ALL} || $ENV{LC_MESSAGES} || $ENV{LANG};
+
+ c::bindtextdomain('libDrakX', $localedir);
+
+ foreach (split ':', $lang) {
+ my $f = "$localedir/$_/$suffix";
+ -s $f and return $_;
+
+ if ($::isInstall) {
+ # cleanup
+ eval { commands::rm("-r", $localedir) };
+ eval { commands::mkdir_("-p", dirname("$localedir/$_/$suffix")) };
+ install_any::getAndSaveFile ("$localedir/$_/$suffix");
+
+ -s $f and return $_;
+ }
}
- $s .= ");";
- no strict "vars";
- eval $s;
- !$@;
+ '';
}
+
sub console_font_files {
map { -e $_ ? $_ : "$_.gz" }
(map { "/usr/lib/kbd/consolefonts/$_.psf" } uniq grep {$_} map { $_->[0] } values %charsets),
diff --git a/perl-install/share/po/.cvsignore b/perl-install/share/po/.cvsignore
index 9eccd17f0..f3dcd7811 100644
--- a/perl-install/share/po/.cvsignore
+++ b/perl-install/share/po/.cvsignore
@@ -1,2 +1,3 @@
.*.sw?
+*.mo
*~
diff --git a/perl-install/share/po/Makefile b/perl-install/share/po/Makefile
index 1e2f640ce..43b32542a 100644
--- a/perl-install/share/po/Makefile
+++ b/perl-install/share/po/Makefile
@@ -2,17 +2,21 @@ include ../../Makefile.config
PMSFILES = $(wildcard $(PMS:%=../../%))
PMSCFILES = $(PMSFILES:%=%_.c)
+
POFILES = $(shell ls *.po)
-PERL2C =
+MOFILES = $(POFILES:%.po=%.mo)
+LANGS = $(POFILES:%.po=%)
-all: $(POFILES)
+LOCALEDIR=$(DATADIR)/locale
-clean:
- rm -f empty.po tmp.* messages tmp.pot $(POFILES:%=%t) $(PMSCFILES)
-verif:
- perl -ne '/^\s*#/ or $$i += my @l = /\b__?\(/g; END { print "$$i\n" }' $(PMSFILES)
- perl -ne '$$i += my @l = /\.c:/g; END { print "$$i\n" }' DrakX.pot
+all: $(MOFILES)
+
+%.mo: %.po
+ msgfmt -o $@ $<
+
+$(PMSCFILES): %_.c: %
+ ./fake_c.pl $< > $@
$(POFILES): DrakX.pot
cp -f $@ $@t
@@ -25,6 +29,19 @@ DrakX.pot: $(PMSFILES)
rm $(PMSCFILES)
perl i18n_compssUsers 2>/dev/null >> $@
+install:
+ for l in $(LANGS); do \
+ install -d $(LOCALEDIR)/$$l/LC_MESSAGES; \
+ install -m 644 $$l.mo $(LOCALEDIR)/$$l/LC_MESSAGES/$(NAME).mo; \
+ done
+
+clean:
+ rm -f empty.po tmp.* messages tmp.pot *.mo $(POFILES:%=%t) $(PMSCFILES)
+
+verif:
+ perl -ne '/^\s*#/ or $$i += my @l = /\b__?\(/g; END { print "$$i\n" }' $(PMSFILES)
+ perl -ne '$$i += my @l = /\.c:/g; END { print "$$i\n" }' DrakX.pot
+
verif2:
# perl -I ../.. -Mcommon -e 'foreach (qw($(PMSFILES))) { printf "package foo%d;\n", ++$$i; print common::cat_($$_) }' | perl -ne 'print if !/use (diagnostics|vars|strict)/' | OUTFILE=tmp.pm perl -I. -I../.. -Mb_dump_strings >/dev/null 2>/dev/null
perl -pe 's|$$|\\n\\|' tmp.pm > tmp.pm_.c
@@ -33,7 +50,5 @@ verif2:
grep "^msgid" tmp.pot | sort > tmp.pot.light
grep "^msgid" DrakX.pot | sort | diff - tmp.pot.light | grep "^>" || true
-$(PMSCFILES): %_.c: %
- ./fake_c.pl $< > $@
# for i in *.po; do echo -n "$i "; msgfmt -v $i 2>&1; done | perl -e 'print map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, (split)[1] ] } <>'
diff --git a/perl-install/standalone.pm b/perl-install/standalone.pm
index 2b403d567..b74253f72 100644
--- a/perl-install/standalone.pm
+++ b/perl-install/standalone.pm
@@ -1,9 +1,14 @@
package standalone; # $Id$
+use c;
+
$::isStandalone = 1;
$ENV{SHARE_PATH} ||= "/usr/share";
+c::setlocale();
+c::bindtextdomain('libDrakX', "/usr/share/locale");
+
sub pkgs_install {
my ($in, @l) = @_;