diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 58135d1455..291cffd8b6 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -3230,7 +3230,7 @@ gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister* page) if (show) { - char *str = gnc_g_list_stringjoin (show, ", "); + char *str = gnc_list_formatter (show); t_list = g_list_prepend (t_list, g_strdup_printf ("%s %s", _("Show:"), str)); g_free (str); @@ -3238,7 +3238,7 @@ gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister* page) if (hide) { - char *str = gnc_g_list_stringjoin (hide, ", "); + char *str = gnc_list_formatter (hide); t_list = g_list_prepend (t_list, g_strdup_printf ("%s %s", _("Hide:"), str)); g_free (str); diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp index 5a8eb41ca2..ef2991d523 100644 --- a/gnucash/import-export/import-main-matcher.cpp +++ b/gnucash/import-export/import-main-matcher.cpp @@ -1871,12 +1871,11 @@ get_peer_acct_names (Split *split) (g_list_find (accounts_seen, account))) continue; gchar *name = gnc_account_get_full_name (account); - names = g_list_prepend (names, g_strdup_printf ("\"%s\"", name)); + names = g_list_prepend (names, name); accounts_seen = g_list_prepend (accounts_seen, account); - g_free (name); } names = g_list_sort (names, (GCompareFunc)g_utf8_collate); - gchar *retval = gnc_g_list_stringjoin (names, ", "); + auto retval = gnc_list_formatter (names); g_list_free_full (names, g_free); g_list_free (accounts_seen); return retval; diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp index 3dc541313d..80b309edfb 100644 --- a/libgnucash/engine/gnc-date.cpp +++ b/libgnucash/engine/gnc-date.cpp @@ -46,6 +46,7 @@ #include #include +#include #include "gnc-date.h" #include "gnc-date-p.h" @@ -1656,3 +1657,29 @@ gnc_date_load_funcs (void) Testfuncs *tf = g_slice_new (Testfuncs); return tf; } + + +gchar* +gnc_list_formatter (GList *strings) +{ + g_return_val_if_fail (strings, nullptr); + + UErrorCode status = U_ZERO_ERROR; + auto formatter = icu::ListFormatter::createInstance(status); + std::vector strvec; + icu::UnicodeString result; + std::string retval; + + for (auto n = strings; n; n = g_list_next (n)) + strvec.push_back (static_cast(n->data)); + + formatter->format (strvec.data(), strvec.size(), result, status); + + if (U_FAILURE(status)) + PERR ("Unicode error"); + else + result.toUTF8String(retval); + + delete formatter; + return g_strdup (retval.c_str()); +} diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h index 2193d0de10..fcf2ff5f55 100644 --- a/libgnucash/engine/gnc-date.h +++ b/libgnucash/engine/gnc-date.h @@ -813,6 +813,17 @@ void gnc_gdate_set_prev_fiscal_year_start (GDate *date, const GDate *year_end); * fiscal year. The year field of this argument is ignored. */ void gnc_gdate_set_prev_fiscal_year_end (GDate *date, const GDate *year_end); + + +/** This function takes a GList of char*, and uses locale-sensitive + * list formatter. + * + * @param strings The GList* of char*. + * + * @returns a newly allocated char* + */ +gchar* gnc_list_formatter (GList* strings); + //@} //@}