[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] q2c: Eliminate many translations for generated .c files.
From: |
John Darrington |
Subject: |
Re: [PATCH] q2c: Eliminate many translations for generated .c files. |
Date: |
Sat, 9 Apr 2011 07:14:14 +0000 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Sat, Mar 19, 2011 at 05:45:50PM -0700, Ben Pfaff wrote:
Most of the %s directives used in msg() format strings that q2c
generates don't have to be substituted at q2c translation time. By
translating them later, we can eliminate a lot of the work that
translators need to do for q2c-generated fiels.
---
This seems correct to me but I'd like to have another set of eyes
look it over before I push it.
I don't think this is going to work. We would need to add all the generated .c
files to the potfile manifest. That will cause problems because some of the
strings therein have already been translated. Even if we can solve that issue,
it'll been that the potfile will depend on files generated at build time which
is not a good idea. It'll also mean that the potfile comments will get bloated
with references to every generated .c
Instead, I suggest we solve this problem as follows:
1. Create a new function within q2c.c similar to
static void dump_msg (int severity, const char *msg, ...);
2. We can then call this function within q2c.c like this:
dump_msg (SE, N_("`(' expected after %s specifier of %s subcommand."),
s->specname, sbc->name);
and it will generate the following code:
msg (SE, gettext ("`(' expected after %s specifier of %s subcommand."),
"the-specname", "the-name");
3. We will also have to add q2c.c to the list of translatable files.
Does this make sense?
J'
src/language/lexer/q2c.c | 30 ++++++++++++++----------------
tests/language/lexer/q2c.at | 4 ++--
2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c
index d578dbc..37dad5a 100644
--- a/src/language/lexer/q2c.c
+++ b/src/language/lexer/q2c.c
@@ -1500,8 +1500,8 @@ dump_specifier_parse (const specifier *spec, const
subcommand *sbc)
{
dump (1, "if (!lex_match (lexer, T_LPAREN))");
dump (1, "{");
- dump (0, "msg (SE, _(\"`(' expected after %s "
- "specifier of %s subcommand.\"));",
+ dump (0, "msg (SE, _(\"`(' expected after %%s "
+ "specifier of %%s subcommand.\"), \"%s\", \"%s\");",
s->specname, sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1513,8 +1513,8 @@ dump_specifier_parse (const specifier *spec, const
subcommand *sbc)
{
dump (1, "if (!lex_is_integer (lexer))");
dump (1, "{");
- dump (0, "msg (SE, _(\"%s specifier of %s subcommand "
- "requires an integer argument.\"));",
+ dump (0, "msg (SE, _(\"%%s specifier of %%s subcommand "
+ "requires an integer argument.\"), \"%s\", \"%s\");",
s->specname, sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1525,8 +1525,8 @@ dump_specifier_parse (const specifier *spec, const
subcommand *sbc)
{
dump (1, "if (!lex_is_number (lexer))");
dump (1, "{");
- dump (0, "msg (SE, _(\"Number expected after %s "
- "specifier of %s subcommand.\"));",
+ dump (0, "msg (SE, _(\"Number expected after %%s "
+ "specifier of %%s subcommand.\"), \"%s\", \"%s\");",
s->specname, sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1538,8 +1538,8 @@ dump_specifier_parse (const specifier *spec, const
subcommand *sbc)
dump (1, "if (lex_token (lexer) != T_ID "
"&& !lex_is_string (lexer))");
dump (1, "{");
- dump (0, "msg (SE, _(\"%s specifier of %s subcommand "
- "requires a string argument.\"));",
+ dump (0, "msg (SE, _(\"%%s specifier of %%s subcommand "
+ "requires a string argument.\"), \"%s\", \"%s\");",
s->specname, sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1565,8 +1565,8 @@ dump_specifier_parse (const specifier *spec, const
subcommand *sbc)
}
dump (1, "{");
- dump (0, "msg (SE, _(\"Bad argument for %s "
- "specifier of %s subcommand.\"));",
+ dump (0, "msg (SE, _(\"Bad argument for %%s "
+ "specifier of %%s subcommand.\"), \"%s\", \"%s\");",
s->specname, sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1580,7 +1580,7 @@ dump_specifier_parse (const specifier *spec, const
subcommand *sbc)
dump (1, "if (!lex_match (lexer, T_RPAREN))");
dump (1, "{");
dump (0, "msg (SE, _(\"`)' expected after argument for "
- "%s specifier of %s.\"));",
+ "%%s specifier of %%s.\"), \"%s\", \"%s\");",
s->specname, sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1710,7 +1710,7 @@ dump_subcommand (const subcommand *sbc)
dump (0, "x = ss_length (lex_tokss (lexer));");
dump (1, "if (!(%s))", sbc->restriction);
dump (1, "{");
- dump (0, "msg (SE, _(\"String for %s must be %s.\"));",
+ dump (0, "msg (SE, _(\"String for %%s must be %s.\"), \"%s\");",
sbc->name, sbc->message);
dump (0, "goto lossage;");
dump (-1, "}");
@@ -1891,8 +1891,7 @@ dump_parser (int persistent)
{
dump (1, "if (p->sbc_%s > 1)", st_lower (sbc->name));
dump (1, "{");
- dump (0, "msg (SE, _(\"%s subcommand may be given only once.\"));",
- sbc->name);
+ dump (0, "lex_sbc_only_once (\"%s\");", sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
outdent ();
@@ -1946,8 +1945,7 @@ dump_parser (int persistent)
{
dump (0, "if ( 0 == p->sbc_%s)", st_lower (sbc->name));
dump (1, "{");
- dump (0, "msg (SE, _(\"%s subcommand must be given.\"));",
- sbc->name);
+ dump (0, "lex_sbc_missing (lexer, \"%s\");", sbc->name);
dump (0, "goto lossage;");
dump (-1, "}");
dump_blank_line (0);
diff --git a/tests/language/lexer/q2c.at b/tests/language/lexer/q2c.at
index eeeed8d..3e4eb68 100644
--- a/tests/language/lexer/q2c.at
+++ b/tests/language/lexer/q2c.at
@@ -14,10 +14,10 @@ ONEWAY.
CROSSTABS.
])
AT_CHECK([pspp -O format=csv q2c.sps], [1], [dnl
-q2c.sps:8: error: EXAMINE: VARIABLES subcommand must be given.
+q2c.sps:8: error: EXAMINE: Syntax error at end of command: missing
required subcommand VARIABLES.
q2c.sps:9: error: ONEWAY: Syntax error at end of command: expecting
variable name.
-q2c.sps:10: error: CROSSTABS: TABLES subcommand must be given.
+q2c.sps:10: error: CROSSTABS: Syntax error at end of command: missing
required subcommand TABLES.
])
AT_CLEANUP
--
1.7.2.3
_______________________________________________
pspp-dev mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/pspp-dev
--
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.
signature.asc
Description: Digital signature
- Re: [PATCH] q2c: Eliminate many translations for generated .c files.,
John Darrington <=