Mark forgotten error messages in gnc-sx-instance-model.c translatable

and report them bilingual:
 *  in g_critical untranslated and
 *  in g_list_append translated.
This commit is contained in:
fell 2018-02-19 11:50:10 +01:00
parent c6cbac588e
commit ce715862fe
2 changed files with 35 additions and 51 deletions

View File

@ -991,14 +991,10 @@ _get_template_split_account(const SchedXaction* sx, const Split *template_split,
NULL); NULL);
if (kvp_val == NULL) if (kvp_val == NULL)
{ {
gchar *err = g_strdup_printf("Null account kvp value for SX [%s], " /* Translators: A list of error messages from the Scheduled Transactions (SX).
"cancelling creation.", * They might appear in their editor or in "Since last run". */
xaccSchedXactionGetName(sx)); gchar *err = N_("Null account kvp value for SX [%s], cancelling creation.");
g_critical("%s", err); REPORT_ERROR(creation_errors, err, xaccSchedXactionGetName(sx));
if (creation_errors != NULL)
*creation_errors = g_list_append(*creation_errors, err);
else
g_free(err);
return FALSE; return FALSE;
} }
acct_guid = kvp_value_get_guid( kvp_val ); acct_guid = kvp_value_get_guid( kvp_val );
@ -1006,15 +1002,9 @@ _get_template_split_account(const SchedXaction* sx, const Split *template_split,
if (*split_acct == NULL) if (*split_acct == NULL)
{ {
char guid_str[GUID_ENCODING_LENGTH+1]; char guid_str[GUID_ENCODING_LENGTH+1];
gchar* err; gchar* err = N_("Unknown account for guid [%s], cancelling SX [%s] creation.");
guid_to_string_buff((const GncGUID*)acct_guid, guid_str); guid_to_string_buff((const GncGUID*)acct_guid, guid_str);
err = g_strdup_printf ("Unknown account for guid [%s], cancelling SX [%s] creation.", REPORT_ERROR(creation_errors, err, guid_str, xaccSchedXactionGetName(sx));
guid_str, xaccSchedXactionGetName(sx));
g_critical("%s", err);
if (creation_errors != NULL)
*creation_errors = g_list_append(*creation_errors, err);
else
g_free(err);
return FALSE; return FALSE;
} }
@ -1065,18 +1055,14 @@ _get_sx_formula_value(const SchedXaction* sx, const Split *template_split, gnc_n
&parseErrorLoc, &parseErrorLoc,
parser_vars)) parser_vars))
{ {
gchar *err = g_strdup_printf ("Error parsing SX [%s] key [%s]=formula [%s] at [%s]: %s", gchar *err = N_("Error parsing SX [%s] key [%s]=formula [%s] at [%s]: %s.");
xaccSchedXactionGetName(sx), REPORT_ERROR(creation_errors, err,
formula_key, xaccSchedXactionGetName(sx),
formula_str, formula_key,
parseErrorLoc, formula_str,
gnc_exp_parser_error_string()); parseErrorLoc,
g_critical ("%s", err); gnc_exp_parser_error_string());
if (creation_errors != NULL) }
*creation_errors = g_list_append(*creation_errors, err);
else
g_free (err);
}
if (parser_vars != NULL) if (parser_vars != NULL)
{ {
@ -1123,14 +1109,9 @@ split_apply_formulas (const Split *split, SxTxnCreationData* creation_data)
gncn_error = gnc_numeric_check(final); gncn_error = gnc_numeric_check(final);
if (gncn_error != GNC_ERROR_OK) if (gncn_error != GNC_ERROR_OK)
{ {
gchar *err = g_strdup_printf ("error %d in SX [%s] final gnc_numeric value, using 0 instead", gchar *err = N_("Error %d in SX [%s] final gnc_numeric value, using 0 instead.");
REPORT_ERROR(creation_data->creation_errors, err,
gncn_error, xaccSchedXactionGetName(sx)); gncn_error, xaccSchedXactionGetName(sx));
g_critical("%s", err);
if (creation_data->creation_errors != NULL)
*creation_data->creation_errors =
g_list_append(*creation_data->creation_errors, err);
else
g_free (err);
final = gnc_numeric_zero(); final = gnc_numeric_zero();
} }
return final; return final;
@ -1754,28 +1735,20 @@ create_cashflow_helper(Transaction *template_txn, void *user_data)
gncn_error = gnc_numeric_check(final); gncn_error = gnc_numeric_check(final);
if (gncn_error != GNC_ERROR_OK) if (gncn_error != GNC_ERROR_OK)
{ {
gchar* err = g_strdup_printf ("error %d in SX [%s] final gnc_numeric value, using 0 instead", gchar* err = N_("Error %d in SX [%s] final gnc_numeric value, using 0 instead.");
gncn_error, xaccSchedXactionGetName(creation_data->sx)); REPORT_ERROR(creation_data->creation_errors, err,
g_critical("%s", err); gncn_error, xaccSchedXactionGetName(creation_data->sx));
if (creation_data->creation_errors != NULL)
*creation_data->creation_errors = g_list_append(*creation_data->creation_errors, err);
else
g_free (err);
final = gnc_numeric_zero(); final = gnc_numeric_zero();
} }
/* Print error message if we would have needed an exchange rate */ /* Print error message if we would have needed an exchange rate */
if (! gnc_commodity_equal(split_cmdty, first_cmdty)) if (! gnc_commodity_equal(split_cmdty, first_cmdty))
{ {
gchar* err = g_strdup_printf ("No exchange rate available in SX [%s] for %s -> %s, value is zero", gchar *err = N_("No exchange rate available in SX [%s] for %s -> %s, value is zero.");
xaccSchedXactionGetName(creation_data->sx), REPORT_ERROR(creation_data->creation_errors, err,
gnc_commodity_get_mnemonic(split_cmdty), xaccSchedXactionGetName(creation_data->sx),
gnc_commodity_get_mnemonic(first_cmdty)); gnc_commodity_get_mnemonic(split_cmdty),
g_critical("%s", err); gnc_commodity_get_mnemonic(first_cmdty));
if (creation_data->creation_errors != NULL)
*creation_data->creation_errors = g_list_append(*creation_data->creation_errors, err);
else
g_free(err);
final = gnc_numeric_zero(); final = gnc_numeric_zero();
} }

View File

@ -258,4 +258,15 @@ GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_e
G_END_DECLS G_END_DECLS
/** Report errors bilingual:
* in g_critical untranslated and
* in g_list_append translated.
*/
#define REPORT_ERROR(list, format, ...) do { \
g_critical(format, __VA_ARGS__); \
if (list != NULL) \
*list = g_list_append(*list, g_strdup_printf(_(format), __VA_ARGS__)); \
} while (0)
#endif // _GNC_SX_INSTANCE_MODEL_H #endif // _GNC_SX_INSTANCE_MODEL_H