summaryrefslogtreecommitdiffstats
path: root/perl-install/share
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-09-09 19:57:59 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-09-09 19:57:59 +0000
commit6e175e978d62cfd31dca82686ec734ff8dc21c2d (patch)
tree83bb7b247cf2cd1441ea538b49aba6c57989f489 /perl-install/share
parentaf6b243fec2ad4d808d3c4c8e4a61d2639d6ef6e (diff)
downloaddrakx-backup-do-not-use-6e175e978d62cfd31dca82686ec734ff8dc21c2d.tar
drakx-backup-do-not-use-6e175e978d62cfd31dca82686ec734ff8dc21c2d.tar.gz
drakx-backup-do-not-use-6e175e978d62cfd31dca82686ec734ff8dc21c2d.tar.bz2
drakx-backup-do-not-use-6e175e978d62cfd31dca82686ec734ff8dc21c2d.tar.xz
drakx-backup-do-not-use-6e175e978d62cfd31dca82686ec734ff8dc21c2d.zip
xml help handling/enhancing for multi-langs
Diffstat (limited to 'perl-install/share')
-rw-r--r--perl-install/share/po/.cvsignore4
-rw-r--r--perl-install/share/po/Makefile11
-rwxr-xr-xperl-install/share/po/help_xml2pm.pl85
3 files changed, 68 insertions, 32 deletions
diff --git a/perl-install/share/po/.cvsignore b/perl-install/share/po/.cvsignore
index 3cfa69f96..5a11b8d84 100644
--- a/perl-install/share/po/.cvsignore
+++ b/perl-install/share/po/.cvsignore
@@ -1,5 +1,5 @@
.*.sw?
*.mo
*~
-drakx-help.xml
-
+doc
+help-*.po
diff --git a/perl-install/share/po/Makefile b/perl-install/share/po/Makefile
index 1d1a2d4ef..1c9e24f6f 100644
--- a/perl-install/share/po/Makefile
+++ b/perl-install/share/po/Makefile
@@ -10,11 +10,12 @@ LANGS = $(POFILES:%.po=%)
LOCALEDIR=$(DATADIR)/locale
-all: $(MOFILES)
+all: help $(MOFILES)
help:
- wget -q -O drakx-help.xml "http://www.mandrakelinux.com/cgi-bin/cvsweb.cgi/~checkout~/doc/manual/literal/drakx/en/drakx-help.xml?rev=1&content-type=text/plain"
- ./help_xml2pm.pl drakx-help.xml | LC_ALL=fr iconv -f utf8 -t ascii//TRANSLIT > ../../help.pm
+ cvs co doc/manual/{entities,literal/drakx}
+ rm -rf doc/CVS
+ ./help_xml2pm.pl
%.mo: %.po
msgfmt -o $@ $<
@@ -24,7 +25,7 @@ $(PMSCFILES): %_.c: %
$(POFILES): DrakX.pot
cp -f $@ $@t
- msgmerge $@t $< > $@
+ if [ -e help-$@ ]; then msgmerge -C help-$@ $@t $< > $@; else msgmerge $@t $< > $@; fi
rm $@t
DrakX.pot: $(PMSFILES)
@@ -40,7 +41,7 @@ install:
done
clean:
- rm -f drakx-help.xml empty.po tmp.* messages tmp.pot *.mo $(POFILES:%=%t) $(PMSCFILES)
+ rm -rf drakx-help.xml doc empty.po tmp.* messages tmp.pot *.mo $(POFILES:%=%t) $(PMSCFILES)
check:
@grep -F '$$' DrakX.pot && { echo "bad translation strings (contains \$$) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; exit 1; } ||:
diff --git a/perl-install/share/po/help_xml2pm.pl b/perl-install/share/po/help_xml2pm.pl
index cf7f36167..42c3d59c7 100755
--- a/perl-install/share/po/help_xml2pm.pl
+++ b/perl-install/share/po/help_xml2pm.pl
@@ -3,27 +3,52 @@
use XML::Parser;
use MDK::Common;
-@ARGV == 1 or die "usage: help_xml2pm <drakx-help.xml>\n";
-
-my $p = new XML::Parser(Style => 'Tree');
-my $tree = $p->parsefile($ARGV[0]);
-my $help = {};
+my $help;
+my $dir = "doc/manual/literal/drakx";
+my @langs = grep { /^..$/ } all($dir);
+
+my %helps = map {
+ my $lang = $_;
+ my $p = new XML::Parser(Style => 'Tree');
+ my $tree = $p->parsefile("$dir/$lang/drakx-help.xml");
+
+ $lang => rewrite2(rewrite1(@$tree), $lang);
+} @langs;
+
+my $base = delete $helps{en} || die;
+save_help($base);
+
+foreach my $lang (keys %helps) {
+ local *F;
+ open F, "> help-$lang.po";
+ print F "\n";
+ foreach my $id (keys %{$helps{$lang}}) {
+ $base->{$id} or die "$lang:$id doesn't exist in english\n";
+ print F qq(# DO NOT BOTHER TO MODIFY HERE, SEE cvs.mandrakesoft.com:/cooker doc/manual/literal/drakx/$lang/drakx-help.xml\n);
+ print F qq(msgid ""\n");
+ print F join(qq(\\n"\n"), split "\n", $base->{$id});
+ print F qq("\nmsgstr ""\n");
+ print F join(qq(\\n"\n"), split "\n", $helps{$lang}{$id});
+ print F qq("\n\n);
+ }
+}
-# rewrite2 fills in $help
-rewrite2(rewrite1(@$tree));
-print
-q{package help;
+sub save_help {
+ my ($help) = @_;
+ local *F;
+ open F, "| LC_ALL=fr iconv -f utf8 -t ascii//TRANSLIT > ../../help.pm";
+ print F q{package help;
use common;
%steps = (
empty => '',
};
-print qq(
+ print F qq(
$_ =>
__("$help->{$_}"),
) foreach sort keys %$help;
-print ");\n";
-
+ print F ");\n";
+}
# i don't like the default tree format given by XML::Parser,
# rewrite it in my own tree format
@@ -46,7 +71,7 @@ sub rewrite1 {
push @l, rewrite1($tag, $tree);
}
}
- { attr => $attr, tag => $tag, children => \@l };
+ { attr => $attr, tag => lc $tag, children => \@l };
}
# return the list of nodes named $tag
@@ -62,16 +87,22 @@ sub find {
}
sub rewrite2 {
+ my ($tree, $lang) = @_;
+ my $i18ned_open_quote = $ {{ fr => "«", de => "„"}}{$lang};
+ my $i18ned_close_quote = $ {{ fr => "»", de => "“"}}{$lang};
+
+ # rewrite2_ fills in $help
+ $help = {};
+ rewrite2_($tree);
+ $help;
+}
+
+sub rewrite2_ {
my ($tree) = @_;
ref($tree) or return $tree;
- if ($tree->{tag} eq 'screen') {
- '';
- }
-
-
my $text = do {
- my @l = map { rewrite2($_) } @{$tree->{children}};
+ my @l = map { rewrite2_($_) } @{$tree->{children}};
my $text;
foreach (grep { !/^\s*$/ } @l) {
s/^ // if $text =~ /\s$/;
@@ -88,8 +119,10 @@ sub rewrite2 {
$text =~ s/^( ?\n)+//;
$text =~ s/\s+$//;
qq(\n$text\n);
- } elsif (member($tree->{tag}, 'quote', 'citetitle')) {
- qq(``$text'');
+ } elsif (member($tree->{tag}, 'quote', 'citetitle', 'foreignphrase')) {
+ ($i18ned_open_quote || "``") . $text . ($i18ned_close_quote || "''");
+ } elsif ($tree->{tag} eq 'guilabel') {
+ ($i18ned_open_quote || "\\\"") . $text . ($i18ned_close_quote || "\\\"");
} elsif ($tree->{tag} eq 'command') {
qq(\\"$text\\");
} elsif ($tree->{tag} eq 'userinput') {
@@ -106,10 +139,10 @@ sub rewrite2 {
$text =~ s/^/' ' . ($cnt++ ? ' ' : '* ')/emg;
"\n$text\n";
- } elsif (member($tree->{tag}, 'guibutton', 'guimenu', 'guilabel',
+ } elsif (member($tree->{tag}, 'guibutton', 'guimenu',
'emphasis', 'acronym', 'keycap', 'ulink', 'tip', 'note',
'primary', 'indexterm', 'application', 'keycombo',
- 'literal', 'superscript',
+ 'literal', 'superscript', 'xref',
)) {
# ignored tags
$text;
@@ -120,7 +153,7 @@ sub rewrite2 {
$text =~ s/^\s+//;
my @footnotes = map {
- my $s = rewrite2({ %$_, tag => 'para' });
+ my $s = rewrite2_({ %$_, tag => 'para' });
$s =~ s/^\s+//;
"(*) $s";
} find('footnote', $tree);
@@ -135,6 +168,8 @@ sub rewrite2 {
sub aerate {
my ($s) = @_;
- my $s2 = join("\n\n", map { join("\n", warp_text($_)) } split "\n", $s);
+ #- the warp_text column is adjusted so that xgettext do not wrap text around
+ #- which cause msgmerge to add a lot of fuzzy
+ my $s2 = join("\n\n", map { join("\n", warp_text($_, 75)) } split "\n", $s);
$s2;
}