~vcs-imports/bibletime/trunk

« back to all changes in this revision

Viewing changes to pot/extractrc

  • Committer: mgruner
  • Date: 2007-05-08 15:51:07 UTC
  • Revision ID: vcs-imports@canonical.com-20070508155107-0rj7jdmm5ivf8685
-imported source and data files to new svn module
-this is where KDE4-based development will take place

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/perl
 
2
 
 
3
#  NOTE: this script is part of the KDE SDK and added to KDevelop to support KDE 2 application development.
 
4
#  The original is located in the KDE CVS module kdesdk/scripts. It gets installed in the same directory as
 
5
#  the KDevelop binary to be in your PATH.
 
6
#
 
7
#  What it does is extract the strings in an application�s .rc file, e.g. testappui.rc, and writes into the pot file
 
8
#  where the translations are build with (po-files)
 
9
#
 
10
#  Added to KDevelop 2000-10-29, Ralf Nolden (nolden@kde.org)
 
11
 
 
12
$linenr = 0;
 
13
$filename = "";
 
14
@filenames = ();
 
15
 
 
16
sub writeoutstring($)
 
17
{
 
18
   print STDOUT "i18n(\"@_[0]\");\n";
 
19
}
 
20
 
 
21
while (defined ($ARGV[0]))
 
22
{
 
23
   $_ = shift; 
 
24
   $filename = $_; # maybe check for options
 
25
 
 
26
if (! $filename) {
 
27
   print STDERR "no file to open\n";
 
28
   exit 1;
 
29
}
 
30
 
 
31
$string = "";
 
32
$intext = 0;
 
33
 
 
34
open(FILE, $filename);
 
35
while ( <FILE> ) {
 
36
   $linenr++;
 
37
 
 
38
   $string .= $_;   
 
39
   chomp($string);
 
40
 
 
41
   $textstring = '([tT][eE][xX][tT]|string)>';
 
42
 
 
43
   if ($intext == 0) {
 
44
     if ($string =~ /<$textstring/) {
 
45
       $string =~ s/^.*<$textstring//;
 
46
       $intext = 1;
 
47
           $starting_linenr = $linenr;
 
48
     } else {
 
49
       $string = "";
 
50
     }
 
51
   }
 
52
   
 
53
   if (($intext == 1) && ($string =~ /<\/$textstring/)) {
 
54
     my $text = $string;
 
55
     $text =~ s/<\/$textstring.*$//;
 
56
         $text =~ s/&lt;/</g;
 
57
     $text =~ s/&gt;/>/g;
 
58
     $text =~ s/&amp;/&/g; 
 
59
     writeoutstring($text); 
 
60
     $string =~ s/^.*<\/$textstring//;
 
61
     $intext = 0;
 
62
         if ($linenr != $starting_linenr) {
 
63
                print STDERR "there is <text> floating\n";
 
64
     }
 
65
   }
 
66
 
 
67
}
 
68
 
 
69
if ($intext == 1) {
 
70
 print STDERR "parsing error in $filename $linenr\n";
 
71
 exit 1;
 
72
}
 
73
 
 
74
}