summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-09-16 15:01:38 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-09-16 15:01:38 +0000
commite19f763d791333193080bfd088c9b29ea7129a61 (patch)
treeaa5a680cf59a3b8348bd1b3a79c5a706f5b41175
parent842d5a99d0885f15d5e28cf8661e6ba5529e4b15 (diff)
downloadrockbox-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-xtools/genlang49
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
3if(!$ARGV[0]) {
4 print <<MOO
5Usage: lang.pl <file>
6MOO
7;
8 exit;
9}
10
11print <<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
19MOO
20 ;
21
22open(LANG, "<$ARGV[0]");
23while(<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}
49close(LANG);