diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/genlang | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/genlang b/tools/genlang new file mode 100755 index 0000000000..827ceb3949 --- /dev/null +++ b/tools/genlang | |||
@@ -0,0 +1,49 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | if(!$ARGV[0]) { | ||
4 | print <<MOO | ||
5 | Usage: lang.pl <file> | ||
6 | MOO | ||
7 | ; | ||
8 | exit; | ||
9 | } | ||
10 | |||
11 | print <<MOO | ||
12 | /* This file was automaticly generated using genlan */ | ||
13 | /* | ||
14 | * The str() macro/functions is how to access strings that might be | ||
15 | * translated. Use it like str(MACRO) and except a string to be | ||
16 | * returned! | ||
17 | */ | ||
18 | #define str(x) x | ||
19 | MOO | ||
20 | ; | ||
21 | |||
22 | open(LANG, "<$ARGV[0]"); | ||
23 | while(<LANG>) { | ||
24 | if($_ =~ / *\#/) { | ||
25 | # comment | ||
26 | next; | ||
27 | } | ||
28 | if($_ =~ / *([a-z]+): *(.*)/) { | ||
29 | ($var, $value) = ($1, $2); | ||
30 | # print "$var => $value\n"; | ||
31 | |||
32 | $set{$var} = $value; | ||
33 | |||
34 | if($var eq "new") { | ||
35 | # the last one for a single phrase | ||
36 | |||
37 | if(!$value) { | ||
38 | # if not set, get the english version | ||
39 | $value = $set{'eng'}; | ||
40 | } | ||
41 | |||
42 | print "#define ".$set{'id'}." $value\n"; | ||
43 | undef %set; | ||
44 | } | ||
45 | |||
46 | } | ||
47 | |||
48 | } | ||
49 | close(LANG); | ||