From 9b2d13673810ea31d8aa0d2baefae5ae5f5c7335 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Tue, 3 Apr 2018 13:07:17 +0200 Subject: [PATCH 1/2] Check also plain language string in as_component_localized_get If the component doesn't contain translated data for the given locale string, try the plain language string before falling back to C Fixes #166 --- src/as-component.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/as-component.c b/src/as-component.c index 96816697..370092b2 100644 --- a/src/as-component.c +++ b/src/as-component.c @@ -1119,10 +1119,16 @@ as_component_localized_get (AsComponent *cpt, GHashTable *lht) gchar *msg; AsComponentPrivate *priv = GET_PRIVATE (cpt); - msg = g_hash_table_lookup (lht, as_component_get_active_locale (cpt)); + const gchar *comp_locale = as_component_get_active_locale (cpt); + const gchar *comp_lang = as_utils_locale_to_language (comp_locale); + msg = g_hash_table_lookup (lht, comp_locale); if ((msg == NULL) && (!as_flags_contains (priv->value_flags, AS_VALUE_FLAG_NO_TRANSLATION_FALLBACK))) { - /* fall back to untranslated / default */ - msg = g_hash_table_lookup (lht, "C"); + /* fall back to language string */ + msg = g_hash_table_lookup (lht, comp_lang); + if (msg == NULL) { + /* fall back to untranslated / default */ + msg = g_hash_table_lookup (lht, "C"); + } } return msg; From 99293a570e29cacd6ef13edb76fe2d6f33e9834e Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Tue, 3 Apr 2018 13:10:08 +0200 Subject: [PATCH 2/2] Fix whitespace --- src/as-component.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/as-component.c b/src/as-component.c index 370092b2..0377f3ed 100644 --- a/src/as-component.c +++ b/src/as-component.c @@ -1119,13 +1119,13 @@ as_component_localized_get (AsComponent *cpt, GHashTable *lht) gchar *msg; AsComponentPrivate *priv = GET_PRIVATE (cpt); - const gchar *comp_locale = as_component_get_active_locale (cpt); - const gchar *comp_lang = as_utils_locale_to_language (comp_locale); + const gchar *comp_locale = as_component_get_active_locale (cpt); + const gchar *comp_lang = as_utils_locale_to_language (comp_locale); msg = g_hash_table_lookup (lht, comp_locale); if ((msg == NULL) && (!as_flags_contains (priv->value_flags, AS_VALUE_FLAG_NO_TRANSLATION_FALLBACK))) { /* fall back to language string */ - msg = g_hash_table_lookup (lht, comp_lang); - if (msg == NULL) { + msg = g_hash_table_lookup (lht, comp_lang); + if (msg == NULL) { /* fall back to untranslated / default */ msg = g_hash_table_lookup (lht, "C"); }