mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 781634 followup - separate translatable commodity namespace strings from those uses in storage
There is now a separate GNC_COMMODITY_NS_ISO_GUI label to be used everywhere the users needs to read 'Currency namespace'. It's currently set to 'Currencies' and can be translated. It may change in to future to better describe this namespace is restricted to ISO4217 defined currencies as opposed to all the non-formal currencies in vogue today (like bitcoin and friends).
This commit is contained in:
parent
b5b0f60396
commit
cc3010d89b
@ -1660,6 +1660,16 @@ gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns)
|
|||||||
return ns->name;
|
return ns->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gnc_commodity_namespace_get_gui_name (const gnc_commodity_namespace *ns)
|
||||||
|
{
|
||||||
|
if (ns == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (g_strcmp0 (ns->name, GNC_COMMODITY_NS_CURRENCY) == 0)
|
||||||
|
return GNC_COMMODITY_NS_ISO_GUI;
|
||||||
|
return ns->name;
|
||||||
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
|
gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
|
||||||
{
|
{
|
||||||
|
@ -98,14 +98,17 @@ GType gnc_commodity_namespace_get_type(void);
|
|||||||
#define GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES"
|
#define GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES"
|
||||||
/* The ISO define is deprecated in favor of CURRENCY */
|
/* The ISO define is deprecated in favor of CURRENCY */
|
||||||
#define GNC_COMMODITY_NS_ISO "ISO4217"
|
#define GNC_COMMODITY_NS_ISO "ISO4217"
|
||||||
#define GNC_COMMODITY_NS_CURRENCY N_("CURRENCY")
|
#define GNC_COMMODITY_NS_CURRENCY "CURRENCY"
|
||||||
#define GNC_COMMODITY_NS_NASDAQ "NASDAQ"
|
#define GNC_COMMODITY_NS_NASDAQ "NASDAQ"
|
||||||
#define GNC_COMMODITY_NS_NYSE "NYSE"
|
#define GNC_COMMODITY_NS_NYSE "NYSE"
|
||||||
#define GNC_COMMODITY_NS_EUREX "EUREX"
|
#define GNC_COMMODITY_NS_EUREX "EUREX"
|
||||||
#define GNC_COMMODITY_NS_MUTUAL "FUND"
|
#define GNC_COMMODITY_NS_MUTUAL "FUND"
|
||||||
#define GNC_COMMODITY_NS_AMEX "AMEX"
|
#define GNC_COMMODITY_NS_AMEX "AMEX"
|
||||||
#define GNC_COMMODITY_NS_ASX "ASX"
|
#define GNC_COMMODITY_NS_ASX "ASX"
|
||||||
#define GNC_COMMODITY_NS_NONCURRENCY _("ALL NON-CURRENCY")
|
#define GNC_COMMODITY_NS_NONCURRENCY _("All non-currency")
|
||||||
|
/* Delay translation of this one, we use it in both translated and untranslated form
|
||||||
|
when presenting the currency related namespace to the user */
|
||||||
|
#define GNC_COMMODITY_NS_ISO_GUI N_("Currencies")
|
||||||
|
|
||||||
typedef GList CommodityList;
|
typedef GList CommodityList;
|
||||||
|
|
||||||
@ -804,6 +807,19 @@ gboolean gnc_commodity_table_add_default_data(gnc_commodity_table *table, QofBoo
|
|||||||
* owned by the engine and should not be freed by the caller. */
|
* owned by the engine and should not be freed by the caller. */
|
||||||
const char * gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns) ;
|
const char * gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns) ;
|
||||||
|
|
||||||
|
/** Return the textual name of a namespace data strucure in a form suitable to
|
||||||
|
* present to the user.
|
||||||
|
*
|
||||||
|
* @param ns A pointer to the namespace data strucure.
|
||||||
|
*
|
||||||
|
* @return A pointer to the gui friendly name of the namespace. This string is
|
||||||
|
* owned by the engine and should not be freed by the caller.
|
||||||
|
*
|
||||||
|
* @notes The returned string is marked for translation, but not translated yet.
|
||||||
|
* If you want it translated pass the return value on to gettext.
|
||||||
|
*/
|
||||||
|
const char * gnc_commodity_namespace_get_gui_name (const gnc_commodity_namespace *ns) ;
|
||||||
|
|
||||||
|
|
||||||
/** Return a list of all commodity data structures in the specified namespace.
|
/** Return a list of all commodity data structures in the specified namespace.
|
||||||
*
|
*
|
||||||
|
@ -605,27 +605,46 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe,
|
|||||||
namespaces = g_list_prepend (NULL, GNC_COMMODITY_NS_CURRENCY);
|
namespaces = g_list_prepend (NULL, GNC_COMMODITY_NS_CURRENCY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* First insert "ALL" */
|
|
||||||
|
/* First insert "Currencies" entry if requested */
|
||||||
|
if (mode == DIAG_COMM_CURRENCY || mode == DIAG_COMM_ALL)
|
||||||
|
{
|
||||||
|
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0,
|
||||||
|
_(GNC_COMMODITY_NS_ISO_GUI), -1);
|
||||||
|
|
||||||
|
if (init_string &&
|
||||||
|
(g_utf8_collate(GNC_COMMODITY_NS_ISO_GUI, init_string) == 0))
|
||||||
|
{
|
||||||
|
matched = TRUE;
|
||||||
|
match = iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next insert insert "All non-currency" entry if requested */
|
||||||
if (mode == DIAG_COMM_NON_CURRENCY_SELECT || mode == DIAG_COMM_ALL)
|
if (mode == DIAG_COMM_NON_CURRENCY_SELECT || mode == DIAG_COMM_ALL)
|
||||||
{
|
{
|
||||||
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
||||||
gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0,
|
gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0,
|
||||||
GNC_COMMODITY_NS_NONCURRENCY, -1);
|
GNC_COMMODITY_NS_NONCURRENCY, -1);
|
||||||
}
|
}
|
||||||
/* add them to the combobox */
|
|
||||||
|
/* add all others to the combobox */
|
||||||
namespaces = g_list_sort(namespaces, collate);
|
namespaces = g_list_sort(namespaces, collate);
|
||||||
for (node = namespaces; node; node = node->next)
|
for (node = namespaces; node; node = node->next)
|
||||||
{
|
{
|
||||||
if (g_utf8_collate(node->data, GNC_COMMODITY_NS_LEGACY) == 0)
|
/* Skip template, legacy and currency namespaces.
|
||||||
|
The latter was added as first entry earlier */
|
||||||
|
if ((g_utf8_collate(node->data, GNC_COMMODITY_NS_LEGACY) == 0) ||
|
||||||
|
(g_utf8_collate(node->data, "template" ) == 0) ||
|
||||||
|
(g_utf8_collate(node->data, GNC_COMMODITY_NS_CURRENCY ) == 0))
|
||||||
continue;
|
continue;
|
||||||
/* Hide the template entry */
|
|
||||||
if (g_utf8_collate(node->data, "template" ) != 0)
|
|
||||||
{
|
|
||||||
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
|
||||||
gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, _(node->data), -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (init_string && (g_utf8_collate(node->data, init_string) == 0))
|
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, node->data, -1);
|
||||||
|
|
||||||
|
if (init_string &&
|
||||||
|
(g_utf8_collate(node->data, init_string) == 0))
|
||||||
{
|
{
|
||||||
matched = TRUE;
|
matched = TRUE;
|
||||||
match = iter;
|
match = iter;
|
||||||
@ -648,16 +667,11 @@ gnc_ui_namespace_picker_ns (GtkWidget *cbwe)
|
|||||||
|
|
||||||
name_space = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(cbwe)))));
|
name_space = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(cbwe)))));
|
||||||
|
|
||||||
if (g_strcmp0 (name_space, GNC_COMMODITY_NS_ISO) == 0)
|
/* Map several currency related names to one common namespace */
|
||||||
{
|
if ((g_strcmp0 (name_space, GNC_COMMODITY_NS_ISO) == 0) ||
|
||||||
/* In case the user types in ISO4217, map it to CURRENCY. */
|
(g_strcmp0 (name_space, GNC_COMMODITY_NS_ISO_GUI) == 0) ||
|
||||||
|
(g_strcmp0 (name_space, _(GNC_COMMODITY_NS_ISO_GUI)) == 0))
|
||||||
return g_strdup(GNC_COMMODITY_NS_CURRENCY);
|
return g_strdup(GNC_COMMODITY_NS_CURRENCY);
|
||||||
}
|
|
||||||
else if (g_strcmp0 (name_space, _(GNC_COMMODITY_NS_CURRENCY)) == 0)
|
|
||||||
{
|
|
||||||
/* In case the user entered a translation of CURRENCY, return it untranslated. */
|
|
||||||
return g_strdup(GNC_COMMODITY_NS_CURRENCY);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return g_strdup(name_space);
|
return g_strdup(name_space);
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ gnc_tree_model_commodity_get_value (GtkTreeModel *tree_model,
|
|||||||
{
|
{
|
||||||
case GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE:
|
case GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE:
|
||||||
g_value_init (value, G_TYPE_STRING);
|
g_value_init (value, G_TYPE_STRING);
|
||||||
g_value_set_string (value, gnc_commodity_namespace_get_name (name_space));
|
g_value_set_string (value, _(gnc_commodity_namespace_get_gui_name (name_space)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_value_init (value, G_TYPE_STRING);
|
g_value_init (value, G_TYPE_STRING);
|
||||||
|
@ -708,7 +708,7 @@ gnc_tree_model_price_get_value (GtkTreeModel *tree_model,
|
|||||||
{
|
{
|
||||||
case GNC_TREE_MODEL_PRICE_COL_COMMODITY:
|
case GNC_TREE_MODEL_PRICE_COL_COMMODITY:
|
||||||
g_value_init (value, G_TYPE_STRING);
|
g_value_init (value, G_TYPE_STRING);
|
||||||
g_value_set_string (value, gnc_commodity_namespace_get_name (name_space));
|
g_value_set_string (value, gnc_commodity_namespace_get_gui_name (name_space));
|
||||||
break;
|
break;
|
||||||
case GNC_TREE_MODEL_PRICE_COL_VISIBILITY:
|
case GNC_TREE_MODEL_PRICE_COL_VISIBILITY:
|
||||||
g_value_init (value, G_TYPE_BOOLEAN);
|
g_value_init (value, G_TYPE_BOOLEAN);
|
||||||
|
@ -223,8 +223,8 @@ sort_namespace (GtkTreeModel *f_model,
|
|||||||
|
|
||||||
ns_a = gnc_tree_model_commodity_get_namespace (model, &iter_a);
|
ns_a = gnc_tree_model_commodity_get_namespace (model, &iter_a);
|
||||||
ns_b = gnc_tree_model_commodity_get_namespace (model, &iter_b);
|
ns_b = gnc_tree_model_commodity_get_namespace (model, &iter_b);
|
||||||
return safe_utf8_collate (gnc_commodity_namespace_get_name (ns_a),
|
return safe_utf8_collate (gnc_commodity_namespace_get_gui_name (ns_a),
|
||||||
gnc_commodity_namespace_get_name (ns_b));
|
gnc_commodity_namespace_get_gui_name (ns_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -205,8 +205,8 @@ sort_ns_or_cm (GtkTreeModel *f_model,
|
|||||||
{
|
{
|
||||||
ns_a = gnc_tree_model_price_get_namespace (model, &iter_a);
|
ns_a = gnc_tree_model_price_get_namespace (model, &iter_a);
|
||||||
ns_b = gnc_tree_model_price_get_namespace (model, &iter_b);
|
ns_b = gnc_tree_model_price_get_namespace (model, &iter_b);
|
||||||
return safe_utf8_collate (gnc_commodity_namespace_get_name (ns_a),
|
return safe_utf8_collate (gnc_commodity_namespace_get_gui_name (ns_a),
|
||||||
gnc_commodity_namespace_get_name (ns_b));
|
gnc_commodity_namespace_get_gui_name (ns_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
comm_a = gnc_tree_model_price_get_commodity (model, &iter_a);
|
comm_a = gnc_tree_model_price_get_commodity (model, &iter_a);
|
||||||
|
Loading…
Reference in New Issue
Block a user