]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/usr/bin/perl\r |
2 | #\r | |
3 | # This file is part of the IPCop Firewall.\r | |
4 | #\r | |
5 | # IPCop is free software; you can redistribute it and/or modify\r | |
6 | # it under the terms of the GNU General Public License as published by\r | |
7 | # the Free Software Foundation; either version 2 of the License, or\r | |
8 | # (at your option) any later version.\r | |
9 | #\r | |
10 | # IPCop is distributed in the hope that it will be useful,\r | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
13 | # GNU General Public License for more details.\r | |
14 | #\r | |
15 | # You should have received a copy of the GNU General Public License\r | |
16 | # along with IPCop; if not, write to the Free Software\r | |
17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r | |
18 | #\r | |
19 | # Copyright (C) 2003-02-04 Mark Wormgoor <mark@wormgoor.com>\r | |
20 | #\r | |
21 | \r | |
22 | # Usage:\r | |
23 | #\r | |
24 | # ./tools/cvs2sql.pl | grep -e INSERT -e UPDATE > lang_data.sql\r | |
25 | #\r | |
26 | \r | |
27 | # Get time\r | |
28 | ($sec, $min, $hour, $day, $month, $year, $weekday, $dayofyear, $isdst) = localtime(time);\r | |
29 | $year += 1900;\r | |
30 | if ($month < 10) { $month = "0" . $month; }\r | |
31 | if ($day < 10) { $day = "0" . $day; }\r | |
32 | if ($hour < 10) { $hour = "0" . $hour; }\r | |
33 | if ($min < 10) { $min = "0" . $min; }\r | |
34 | if ($sec < 10) { $sec = "0" . $sec; }\r | |
35 | $lastchange = "$year$month$day$hour$sec";\r | |
36 | \r | |
37 | # Read English install file\r | |
38 | undef $/;\r | |
39 | open (FILE, "langs/en/install/lang_en.c") or die "Couldn't open English language file";\r | |
40 | $file = <FILE>;\r | |
41 | close (FILE);\r | |
42 | $file =~ s/"\s*\\\s*\n"//g;\r | |
43 | $file =~ s/",/"/g;\r | |
44 | $file =~ s/\\n/\\\\n/g;\r | |
45 | $file =~ s/^.*(TR_[\w]+).*$/$1/gm;\r | |
46 | $file =~ s/(TR_\w+)\n(.*$)/INSERT INTO Lang_Data (VarName, EN_Word, Section, LastChange) Values ("$1", $2, "SETUP", "$lastchange");/gm;\r | |
47 | print "$file";\r | |
48 | \r | |
49 | # Read English Perl file\r | |
50 | do "langs/en/cgi-bin/en.pl" or die "Failed to open English web language file";\r | |
51 | while( my ($key, $value) = each(%tr) ) {\r | |
52 | $key = lc($key);\r | |
53 | $value =~ s/\n//mg;\r | |
54 | $value =~ s/\\*\"/\\"/g;\r | |
55 | print "INSERT INTO Lang_Data (VarName, EN_Word, Section, LastChange) Values (\"$key\", \"$value\", \"WEB\", \"$lastchange\");\n";\r | |
56 | }\r | |
57 | \r | |
58 | # Other language install files\r | |
59 | while (($trans = glob("langs/*/install/lang_*.c") )) {\r | |
60 | if ( $trans =~ /lang_en.c/ ) { next; }\r | |
61 | if ( $trans =~ /lang_el.c/ ) { next; }\r | |
62 | open (FILE, "$trans") or die "Couldn't open language file: $trans";\r | |
63 | $file = <FILE>;\r | |
64 | close (FILE);\r | |
65 | $trans =~ s/.*lang_(.*).c/$1/;\r | |
66 | $trans = uc($trans);\r | |
67 | $file =~ s/"\s*\\\s*\n"//g;\r | |
68 | $file =~ s/",/"/g;\r | |
69 | $file =~ s/\\n/\\\\n/g;\r | |
70 | $file =~ s/^.*(TR_[\w]+).*$/$1/gm;\r | |
71 | $file =~ s/(TR_\w+)\n(.*$)/UPDATE Lang_Data set ${trans}_Word = $2 where VarName = "$1";/gm;\r | |
72 | print "$file";\r | |
73 | }\r | |
74 | \r | |
75 | # Other language perl files\r | |
76 | while (($trans = glob("langs/*/cgi-bin/*.pl") )) {\r | |
77 | if ( $trans =~ /en.pl/ ) { next; }\r | |
78 | if ( $trans =~ /el.pl/ ) { next; }\r | |
79 | %tr=();\r | |
80 | do "$trans" or die "Failed to load translation file: $trans";\r | |
81 | $trans =~ s/.*\/(\w+).pl/$1/;\r | |
82 | $trans = uc($trans);\r | |
83 | while( my ($key, $value) = each(%tr) ) {\r | |
84 | $key = lc($key);\r | |
85 | $value =~ s/\n//mg;\r | |
86 | $value =~ s/\\*\"/\\"/g;\r | |
87 | print "UPDATE Lang_Data set ${trans}_Word = \"$value\" where VarName = \"$key\";\n";\r | |
88 | }\r | |
89 | }\r |