generate a lang.h file from a .lang input

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2301 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2002-09-16 15:01:38 +00:00
parent 842d5a99d0
commit e19f763d79

49
tools/genlang Executable file
View file

@ -0,0 +1,49 @@
#!/usr/bin/perl
if(!$ARGV[0]) {
print <<MOO
Usage: lang.pl <file>
MOO
;
exit;
}
print <<MOO
/* This file was automaticly generated using genlan */
/*
* The str() macro/functions is how to access strings that might be
* translated. Use it like str(MACRO) and except a string to be
* returned!
*/
#define str(x) x
MOO
;
open(LANG, "<$ARGV[0]");
while(<LANG>) {
if($_ =~ / *\#/) {
# comment
next;
}
if($_ =~ / *([a-z]+): *(.*)/) {
($var, $value) = ($1, $2);
# print "$var => $value\n";
$set{$var} = $value;
if($var eq "new") {
# the last one for a single phrase
if(!$value) {
# if not set, get the english version
$value = $set{'eng'};
}
print "#define ".$set{'id'}." $value\n";
undef %set;
}
}
}
close(LANG);