aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2004-01-27 16:42:14 +0000
committerFrederic Lepied <flepied@mandriva.com>2004-01-27 16:42:14 +0000
commitb1e46640724c7cfb702f40c56b05dd10962ac55c (patch)
tree9d03054b8bec45379613d360ab7966747d1a46ec
parent6d24ca244f28aa8441e220e490125482d6916f39 (diff)
downloadspec-helper-b1e46640724c7cfb702f40c56b05dd10962ac55c.tar
spec-helper-b1e46640724c7cfb702f40c56b05dd10962ac55c.tar.gz
spec-helper-b1e46640724c7cfb702f40c56b05dd10962ac55c.tar.bz2
spec-helper-b1e46640724c7cfb702f40c56b05dd10962ac55c.tar.xz
spec-helper-b1e46640724c7cfb702f40c56b05dd10962ac55c.zip
first version
-rwxr-xr-xtranslate_menu.pl65
1 files changed, 65 insertions, 0 deletions
diff --git a/translate_menu.pl b/translate_menu.pl
new file mode 100755
index 0000000..e7a58a9
--- /dev/null
+++ b/translate_menu.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -w
+#---------------------------------------------------------------
+# Project : Mandrake Linux
+# Module : spec-helper
+# File : translate_menu.pl
+# Version : $Id$
+# Author : Frederic Lepied
+# Created On : Mon Jan 26 13:37:49 2004
+# Purpose : change the menu sections
+#---------------------------------------------------------------
+
+@nested = (["Configuration", "System/Configuration"],
+
+ ["Applications/Monitoring", "System/Monitoring"],
+ ["Applications/Publishing", "Office/Publishing"],
+ ["Applications/File tools", "System/File tools"],
+ ["Applications/Text tools", "System/Text tools"],
+ ["Applications/Archiving", "System/Archiving"],
+ ["Applications", "More applications"],
+
+ ["Terminals", "System/Terminals"],
+
+ ["Documentation", "More applications/Documentation"],
+
+ ["Office/PDA", "Office/Communications/PDA"],
+
+ ["Networking/IRC", "Internet/Chat"],
+ ["Networking/WWW", "Internet/Web browsers"],
+ ["Networking", "Internet"],
+
+ ["Amusement", "More applications/Games"],
+ ["Session/Windowmanagers", "System/Session/Windowmanagers"],
+ );
+
+sub translate {
+ my ($str) = @_;
+
+ foreach my $t (@nested) {
+ if ($str =~ /(.*)$t->[0](.*)/ and not ($str =~ /$t->[1]/) ) {
+ print "$str => $1$t->[1]$2\n";
+ return "$1$t->[1]$2";
+ }
+ }
+ return $str;
+}
+
+# process each file passed on cli:
+foreach my $file (@ARGV) {
+ open (my $FILE, "<$file");
+ my @lines = <$FILE>;
+ close($FILE);
+ open ($FILE, ">$file");
+ for my $l (@lines) {
+ chomp($l);
+ if (( $l =~ /(.*section=")([^"]+)("\s+.*)/ ) or ( $l =~ /(.*section=)([^"].+?)((\s|\\)+.*)/ )) {
+ my ($beg, $section, $end) = ($1, $2, $3);
+ $section = translate($section);
+ $l = "$beg$section$end";
+ }
+ print $FILE "$l\n";
+ }
+ close($FILE);
+}
+
+# translate_menu.pl ends here