summaryrefslogtreecommitdiff
path: root/app/i18n/stripmsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/i18n/stripmsg.c')
-rw-r--r--app/i18n/stripmsg.c23
1 files changed, 20 insertions, 3 deletions
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++;