diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-09-16 15:01:38 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-09-16 15:01:38 +0000 |
commit | e19f763d791333193080bfd088c9b29ea7129a61 (patch) | |
tree | aa5a680cf59a3b8348bd1b3a79c5a706f5b41175 | |
parent | 842d5a99d0885f15d5e28cf8661e6ba5529e4b15 (diff) | |
download | rockbox-e19f763d791333193080bfd088c9b29ea7129a61.tar.gz rockbox-e19f763d791333193080bfd088c9b29ea7129a61.zip |
generate a lang.h file from a .lang input
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2301 a1c6a512-1295-4272-9138-f99709370657
-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); | ||