summaryrefslogtreecommitdiff
path: root/tools/langv1tov2
blob: 61f36b29df4eb7a68dfbd748130519bf95fb8dad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl -s

while(<STDIN>) {
    $line++;
    if($_ =~ / *\#/) {
        # comment
        next;
    }
    # get rid of DOS newlines
    $_ =~ s/\r//g;
    if($_ =~ / *([a-z]+): *(.*)/) {
        ($var, $value) = ($1, $2);
        # print "$var => $value\n";

        $set{$var} = $value;

        if( (($var eq "new") && $value && ($value !~ /^\"(.*)\"\W*$/)) ||
            (($var eq "voice") && $value && ($value !~ /^\"(.*)\"\W*$/)) ||
            (($var eq "eng") && ($value !~ /^\"(.*)\"\W*$/)) ) {
            print "$input:$line:missing quotes for ".$set{'id'}."\n";
            $errors++;
            next;
        }

        if($var eq "new") {
            # the last one for a single phrase

            if(!$value || ($value eq "\"\"") ) {
                # if not set, get the english version
                $value = $set{'eng'};
            }
            print <<MOO
<phrase>
  id: $set{'id'}
  desc: $set{'desc'}
  user:
  <source>
    *: $set{'eng'}
  </source>
  <dest>
    *: $value
  </dest>
  <voice>
    *: $set{'voice'}
  </voice>
</phrase>
MOO
;
            undef %set;
        }

    }

}