From b623f5953691b2a0614e6f1f4def86bdbb9a4113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 8 Aug 2020 11:53:00 +0200 Subject: New upstream version 5.2.0Beta2.1 --- app/i18n/stripmsg.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'app/i18n/stripmsg.c') diff --git a/app/i18n/stripmsg.c b/app/i18n/stripmsg.c index 1e3dc36..6010530 100644 --- a/app/i18n/stripmsg.c +++ b/app/i18n/stripmsg.c @@ -28,18 +28,31 @@ */ typedef enum { MODE_XTR, MODE_XTQ, MODE_TIP } mode_e; +/** + * Write translator comments to messagefile + * + * \param [in,out] file the source file. + * \param line the source line. + */ + +void translatorcomment(char *file, unsigned line) +{ + printf("// i18n: %s:%d\n", file, line); +} /* Process the given input file. */ -void process( mode_e mode, FILE * inFile ) +void process( mode_e mode, FILE * inFile, char *fileName ) { char line[4096]; char * cp; int len; int offset; int i; + unsigned lineNo = 0; while ( fgets( line, sizeof(line), inFile ) != NULL ) { + lineNo++; offset = 0; switch (mode) @@ -47,7 +60,9 @@ void process( mode_e mode, FILE * inFile ) case MODE_XTR: if (strncmp( line, "MESSAGE", 7 ) == 0) { + translatorcomment(fileName, lineNo); while ( ( fgets( line, sizeof(line), inFile ) ) != NULL ) { + lineNo++; if ( strncmp(line, "END", 3) == 0) /* End of message block */ break; @@ -110,6 +125,7 @@ void process( mode_e mode, FILE * inFile ) line[len] = '\0'; if (len == 0) break; + translatorcomment(fileName, lineNo); printf("N_(\"%s\");\n", line+offset); } break; // case MODE_XTQ: @@ -130,6 +146,7 @@ void process( mode_e mode, FILE * inFile ) cp[1] = '\0'; + translatorcomment(fileName, lineNo); /* if line ended with a continuation sign, get the rest */ while (*cp=='\\') { *cp++ = '\\'; @@ -139,7 +156,7 @@ void process( mode_e mode, FILE * inFile ) if (!fgets( cp, (sizeof(line)) - (cp-line), inFile )) { return; } - + lineNo++; /* lines starting with hash sign are ignored (comments) */ if (*cp=='#') continue; @@ -239,7 +256,7 @@ int main ( int argc, char * argv[] ) } /* Process file */ - process( mode, inFile ); + process( mode, inFile, argv[i] ); /* Close file */ files++; -- cgit v1.2.3