diff --git a/man/remind.1.in b/man/remind.1.in index 42bc1734..2ebb2f48 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -318,6 +318,10 @@ tree. This is unlikely to be useful unless you are working on .TP .B h Dump hash-table statistics on exit. +.TP +.B q +Output a TRANSLATE command each time the \fB_()\fR built-in function +is called or the \fB%(...)\fR substitution sequence is encountered. .RE .TP \fB\-g\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR]]]] @@ -5790,6 +5794,14 @@ you can update it by running: .PP and then editing \fBmylang-update.rem\fR to add in the missing translations. .PP +If you have some reminder scripts that use the \fB_()\fR built-in function +or \fB%(...)\fR substitution sequence, you can generate a list of needed +TRANSLATE commands by running: +.PP +.nf + remind -q -n -dq myscript.rem 2>&1 | grep ^TRANSLATE | sort | uniq +.fi +.PP Note that if you \fBSET\fR various translation-related system variables such as \fB$Monday\fR, \fB$December\fR, \fB$Ago\fR, etc, then \fBRemind\fR \fIalso\fR makes a corresponding translation diff --git a/src/dosubst.c b/src/dosubst.c index d59bc563..758dfae2 100644 --- a/src/dosubst.c +++ b/src/dosubst.c @@ -240,6 +240,9 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, } else { err = DBufPuts(dbuf, DBufValue(&orig)); } + if (DebugFlag & DB_TRANSLATE) { + TranslationTemplate(DBufValue(&orig)); + } DBufFree(&orig); DBufFree(&translated); if (err) return err; diff --git a/src/funcs.c b/src/funcs.c index bc405899..0076f637 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -392,6 +392,9 @@ static int F_(func_info *info) } r = RetStrVal(DBufValue(&translated), info); DBufFree(&translated); + if (DebugFlag & DB_TRANSLATE) { + TranslationTemplate(ARGSTR(0)); + } return r; } diff --git a/src/init.c b/src/init.c index e8865493..ac0b1535 100644 --- a/src/init.c +++ b/src/init.c @@ -642,6 +642,7 @@ void InitRemind(int argc, char const *argv[]) case 'v': case 'V': DebugFlag |= DB_DUMP_VARS; break; case 'l': case 'L': DebugFlag |= DB_PRTLINE; break; case 'f': case 'F': DebugFlag |= DB_TRACE_FILES; break; + case 'q': case 'Q': DebugFlag |= DB_TRANSLATE; break; default: fprintf(ErrFp, GetErr(M_BAD_DB_FLAG), *(arg-1)); fprintf(ErrFp, "\n"); diff --git a/src/main.c b/src/main.c index 5b2c9e56..13bdf5d3 100644 --- a/src/main.c +++ b/src/main.c @@ -1268,6 +1268,12 @@ int DoDebug(ParsePtr p) else DebugFlag &= ~DB_ECHO_LINE; break; + case 'q': + case 'Q': + if (val) DebugFlag |= DB_TRANSLATE; + else DebugFlag &= ~DB_TRANSLATE; + break; + case 's': case 'S': if (val) DebugFlag |= DB_PARSE_EXPR; diff --git a/src/types.h b/src/types.h index ee959c71..37148e8a 100644 --- a/src/types.h +++ b/src/types.h @@ -200,14 +200,15 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */ #define NO_MAX 127 /* DEFINES for debugging flags */ -#define DB_PRTLINE 0x01 -#define DB_PRTEXPR 0x02 -#define DB_PRTTRIG 0x04 -#define DB_DUMP_VARS 0x08 -#define DB_ECHO_LINE 0x10 -#define DB_TRACE_FILES 0x20 -#define DB_PARSE_EXPR 0x40 -#define DB_HASHSTATS 0x80 +#define DB_PRTLINE 0x001 +#define DB_PRTEXPR 0x002 +#define DB_PRTTRIG 0x004 +#define DB_DUMP_VARS 0x008 +#define DB_ECHO_LINE 0x010 +#define DB_TRACE_FILES 0x020 +#define DB_PARSE_EXPR 0x040 +#define DB_HASHSTATS 0x080 +#define DB_TRANSLATE 0x100 /* Enumeration of the tokens */ enum TokTypes