2002-09-17 07:17:25 +00:00
|
|
|
#!/usr/bin/perl -s
|
2002-09-16 15:01:38 +00:00
|
|
|
|
|
|
|
if(!$ARGV[0]) {
|
|
|
|
print <<MOO
|
2002-09-17 07:17:25 +00:00
|
|
|
Usage: lang.pl [-p=<prefix>] <language file>
|
|
|
|
|
|
|
|
When running this program. <prefix>.h and <prefix>.c will be created in the
|
|
|
|
"current directory". <prefix> is "lang" by default.
|
2002-09-16 15:01:38 +00:00
|
|
|
MOO
|
|
|
|
;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2002-09-17 07:17:25 +00:00
|
|
|
my $prefix = $p;
|
|
|
|
if(!$prefix) {
|
|
|
|
$prefix="lang";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $input = $ARGV[0];
|
|
|
|
|
|
|
|
open(HFILE, ">$prefix.h");
|
|
|
|
open(CFILE, ">$prefix.c");
|
|
|
|
|
|
|
|
print HFILE <<MOO
|
|
|
|
/* This file was automaticly generated using genlang */
|
2002-09-16 15:01:38 +00:00
|
|
|
/*
|
|
|
|
* 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!
|
|
|
|
*/
|
2002-09-17 07:17:25 +00:00
|
|
|
#define str(x) language_strings[x]
|
|
|
|
|
|
|
|
/* this is the array with all the strings */
|
|
|
|
extern unsigned char *language_strings[];
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MOO
|
|
|
|
;
|
|
|
|
|
|
|
|
print CFILE <<MOO
|
|
|
|
/* This file was automaticly generated using genlang, the strings come
|
|
|
|
from "$input" */
|
|
|
|
|
|
|
|
unsigned char *language_strings[]={
|
2002-09-16 15:01:38 +00:00
|
|
|
MOO
|
|
|
|
;
|
|
|
|
|
2002-09-17 07:17:25 +00:00
|
|
|
open(LANG, "<$input");
|
2002-09-16 15:01:38 +00:00
|
|
|
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'};
|
|
|
|
}
|
|
|
|
|
2002-09-17 07:17:25 +00:00
|
|
|
print HFILE " ".$set{'id'}.",\n";
|
|
|
|
print CFILE " $value,\n";
|
|
|
|
|
2002-09-16 15:01:38 +00:00
|
|
|
undef %set;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
close(LANG);
|
2002-09-17 07:17:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
print HFILE <<MOO
|
|
|
|
};
|
|
|
|
/* end of generated enum list */
|
|
|
|
MOO
|
|
|
|
;
|
|
|
|
|
|
|
|
print CFILE <<MOO
|
|
|
|
};
|
|
|
|
/* end of generated string list */
|
|
|
|
MOO
|
|
|
|
;
|
|
|
|
|
|
|
|
close(CFILE);
|
|
|
|
close(HFILE);
|