3 * Copyright (C) 2004 Red Hat, Inc.
5 * This is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Library General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 static const char *table = "unknown";
22 extern const char *currentfile;
28 %token ERROR_TABLE_START
29 %token ERROR_TABLE_END
30 %token ERROR_CODE_START
38 statements: statement | statements statement ;
39 statement: table_start | error_code | table_end ;
40 table_start: ERROR_TABLE_START TOKEN { table = $2; };
41 literal: literal LITERAL { $$ = g_strconcat($1, $2, NULL);} | LITERAL;
42 error_code: ERROR_CODE_START TOKEN COMMA QUOTE literal QUOTE {
47 /* Find the basename of the current file. */
48 if (strchr(currentfile, '/') != NULL) {
49 p = strrchr(currentfile, '/') + 1;
53 printf("\n# %s:%s:%s\n", p, table, $2);
54 /* If the string doesn't contain a newline, just print
55 * it on a single line. */
56 if (strchr($5, '\n') == NULL) {
57 printf("msgid \"%s\"\n", $5);
59 /* Split the string up along newline
60 * boundaries, for readability. */
61 lines = g_strsplit($5, "\n", -1);
64 for (i = 0; lines[i] != NULL; i++) {
65 printf("\"%s\"\n", lines[i]);
70 /* Output the template translation. */
71 printf("msgstr \"\"\n");
74 ERROR_CODE_START TOKEN COMMA QUOTE QUOTE {
76 table_end: ERROR_TABLE_END { table = "unknown"; };