diff --git a/ChangeLog b/ChangeLog index 896ea60fb2..279266f377 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-01-10 Christian Stimming + + * src/report/locale-specific/us/gncmod-locale-reports-us.c, + src/tax/us/gncmod-tax-us.c: For German tax categories, make sure + the module name will match the de_DE locale or will fall back to + us module name all the time. + 2004-12-31 Derek Atkins John Ellson's patch to fix some gcc4 warnings (bug #162582). diff --git a/src/report/locale-specific/us/gncmod-locale-reports-us.c b/src/report/locale-specific/us/gncmod-locale-reports-us.c index 0c329cf2d9..608f2b401a 100644 --- a/src/report/locale-specific/us/gncmod-locale-reports-us.c +++ b/src/report/locale-specific/us/gncmod-locale-reports-us.c @@ -33,7 +33,11 @@ int libgncmod_locale_reports_us_LTX_gnc_module_end(int refcount); char * libgncmod_locale_reports_us_LTX_gnc_module_path(void) { - return g_strdup("gnucash/report/locale-specific/us"); + const char *thislocale = setlocale(LC_ALL, NULL); + if (strncmp(thislocale, "de_DE", 5) == 0) + return g_strdup("gnucash/report/locale-specific/de_DE"); + else + return g_strdup("gnucash/report/locale-specific/us"); } char * @@ -43,8 +47,22 @@ libgncmod_locale_reports_us_LTX_gnc_module_description(void) { int libgncmod_locale_reports_us_LTX_gnc_module_init(int refcount) { - /* load us tax info */ - if(!gnc_module_load("gnucash/tax/us", 0)) { + /* load the tax info */ + const char *thislocale = setlocale(LC_ALL, NULL); + /* This is a very simple hack that loads the (new, special) German + tax definition file in a German locale, or (default) loads the + previous US tax file. */ + gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0); + const char *tax_module = is_de_DE ? + "gnucash/tax/de_DE" : + "gnucash/tax/us"; + const char *report_taxtxf = is_de_DE ? + "(use-modules (gnucash report taxtxf-de_DE))" : + "(use-modules (gnucash report taxtxf))"; + + /* The gchar* cast is only because the function declaration expects + a non-const string -- probably an api error. */ + if(!gnc_module_load((gchar*)tax_module, 0)) { return FALSE; } @@ -53,21 +71,10 @@ libgncmod_locale_reports_us_LTX_gnc_module_init(int refcount) { return FALSE; } - const char *report_taxtxf; - /* This is a very simple hack that loads the (new, special) German - tax definition file in a German locale, or (default) loads the - previous US tax file. */ - const char *thislocale = setlocale(LC_ALL, NULL); - if (strncmp(thislocale, "de_DE", 5) == 0) { - report_taxtxf = "(use-modules (gnucash report taxtxf-de_DE))"; - } else { - report_taxtxf = "(use-modules (gnucash report taxtxf))"; - } - /* load the report generation scheme code */ if(scm_c_eval_string(report_taxtxf) == SCM_BOOL_F) { - printf("failed to load (gnucash report taxtxf)\n"); + printf("failed to load %s\n", report_taxtxf); return FALSE; } diff --git a/src/tax/us/gncmod-tax-us.c b/src/tax/us/gncmod-tax-us.c index 421b065100..8b3b089abd 100644 --- a/src/tax/us/gncmod-tax-us.c +++ b/src/tax/us/gncmod-tax-us.c @@ -33,7 +33,11 @@ int libgncmod_tax_us_LTX_gnc_module_end(int refcount); char * libgncmod_tax_us_LTX_gnc_module_path(void) { - return g_strdup("gnucash/tax/us"); + const char *thislocale = setlocale(LC_ALL, NULL); + if (strncmp(thislocale, "de_DE", 5) == 0) + return g_strdup("gnucash/tax/de_DE"); + else + return g_strdup("gnucash/tax/us"); } char *