Commit 10700bf6 authored by Alexandre Julliard's avatar Alexandre Julliard

wrc: Add support for generating .po files from existing resources.

parent 0e79c5c1
DEFS = -D__WINESRC__ -DINCLUDEDIR="\"$(includedir)\"" $(EXTRADEFS)
PROGRAMS = wrc$(EXEEXT) wrc-installed
MANPAGE = wrc.man
ALL_LIBS = @LIBGETTEXTPO@ $(LIBWPP) $(LIBWINE) $(LIBPORT)
C_SRCS = \
dumpres.c \
genres.c \
newstruc.c \
po.c \
readres.c \
translation.c \
utils.c \
......@@ -22,10 +24,10 @@ all: $(PROGRAMS)
@MAKE_RULES@
wrc$(EXEEXT): $(OBJS) $(LIBWPP)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(LDRPATH_LOCAL)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(ALL_LIBS) $(LDFLAGS) $(LDRPATH_LOCAL)
wrc-installed: $(OBJS) $(LIBWPP)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(LDRPATH_INSTALL)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(ALL_LIBS) $(LDFLAGS) $(LDRPATH_INSTALL)
install:: wrc-installed $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) wrc-installed $(DESTDIR)$(bindir)/wrc$(EXEEXT)
......
This diff is collapsed. Click to expand it.
......@@ -69,7 +69,7 @@ static const char usage[] =
" --no-use-temp-file Ignored for compatibility with windres\n"
" --nostdinc Disables searching the standard include path\n"
" -o, --output=FILE Output to file (default is infile.res)\n"
" -O, --output-format=FORMAT The output format (either `res' or `res16`)\n"
" -O, --output-format=FORMAT The output format (`po', `pot', `res', or `res16`)\n"
" --pedantic Enable pedantic warnings\n"
" --preprocessor Specifies the preprocessor to use, including arguments\n"
" -r Ignored for compatibility with rc\n"
......@@ -148,7 +148,7 @@ static int pointer_size = sizeof(void *);
static int verify_translations_mode;
char *output_name = NULL; /* The name given by the -o option */
static char *output_name; /* The name given by the -o option */
char *input_name = NULL; /* The name given on the command-line */
static char *temp_name = NULL; /* Temporary file for preprocess pipe */
......@@ -333,6 +333,7 @@ int main(int argc,char *argv[])
int nb_files = 0;
int i;
int cmdlen;
int po_mode = 0;
char **files = xmalloc( argc * sizeof(*files) );
signal(SIGSEGV, segvhandler);
......@@ -462,7 +463,9 @@ int main(int argc,char *argv[])
else error("Too many output files.\n");
break;
case 'O':
if (strcmp(optarg, "res16") == 0) win32 = 0;
if (strcmp(optarg, "po") == 0) po_mode = 1;
else if (strcmp(optarg, "pot") == 0) po_mode = 2;
else if (strcmp(optarg, "res16") == 0) win32 = 0;
else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg);
break;
case 'r':
......@@ -524,20 +527,10 @@ int main(int argc,char *argv[])
for (i = 0; i < nb_files; i++)
{
input_name = files[i];
if(!output_name && !preprocess_only)
{
output_name = dup_basename(input_name, ".rc");
strcat(output_name, ".res");
}
if (load_file( input_name, output_name )) exit(1);
}
/* stdin special case. NULL means "stdin" for wpp. */
if (nb_files == 0)
{
if(!output_name && !preprocess_only)
output_name = strdup("wrc.tab.res");
if (load_file( NULL, output_name )) exit(1);
}
if (nb_files == 0 && load_file( NULL, output_name )) exit(1);
if(debuglevel & DEBUGLEVEL_DUMP)
dump_resources(resource_top);
......@@ -547,11 +540,31 @@ int main(int argc,char *argv[])
verify_translations(resource_top);
exit(0);
}
if (po_mode)
{
if (po_mode == 2) /* pot file */
{
if (!output_name)
{
output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
strcat( output_name, ".pot" );
}
write_pot_file( output_name );
}
else write_po_files( output_name );
output_name = NULL;
exit(0);
}
/* Convert the internal lists to binary data */
resources2res(resource_top);
chat("Writing .res-file\n");
if (!output_name)
{
output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
strcat(output_name, ".res");
}
write_resfile(output_name, resource_top);
output_name = NULL;
......
......@@ -45,7 +45,6 @@ extern int preprocess_only;
extern int no_preprocess;
extern int check_utf8;
extern char *output_name;
extern char *input_name;
extern char *cmdline;
extern time_t now;
......@@ -57,6 +56,8 @@ extern resource_t *resource_top;
extern language_t *currentlanguage;
void verify_translations(resource_t *top);
void write_pot_file( const char *outname );
void write_po_files( const char *outname );
void write_resfile(char *outname, resource_t *top);
static inline void set_location( location_t *loc )
......
......@@ -93,8 +93,15 @@ with \fB.rc\fR stripped or \fBwrc.tab.res\fR if input is read
from standard input.
.TP
.I \fB\-O\fR, \fB\-\-output\-format\fR=\fIformat\fR
Sets the output format. The supported formats are 'res' and 'res16'.
If this option is not specified, format defaults to 'res'.
Sets the output format. The supported formats are \fBpo\fR, \fBpot\fR,
\fBres\fR, and \fBres16\fR. If this option is not specified, the
format defaults to \fBres\fR.
.br
In \fBpo\fR mode, if an output file name is specified it must match a
known language name, like \fBen_US.po\fR; only resources for the
specified language are output. If no output file name is specified, a
separate .po file is created for every language encountered in the
input.
.TP
.I \fB\-\-pedantic\fR
Enable pedantic warnings. Notably redefinition of #define statements can
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment