summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-06-27 20:28:00 -0400
committerDavid Zeuthen <zeuthen@gmail.com>2012-07-06 09:47:10 -0400
commitfacadfb5c8c52ba45fd20ffe3b6d3ddd4208a427 (patch)
tree467c5d3422c57aae327ec4ee4adc9387fe1bd0dd /src
parentacf3a06e55f9ca8a7f7bfa012c24e8794d27c85f (diff)
downloadpolkit-facadfb5c8c52ba45fd20ffe3b6d3ddd4208a427.tar.gz
Try harder to look up the right localization
The code for looking up localized strings for action descriptions was manually trying to break locale names into pieces, but didn't get it right for e.g. zh_CN.utf-8. Instead, use the GLib function g_get_locale_variants(), which handles this (and more). This fixes the translation problem reported in https://bugzilla.gnome.org/show_bug.cgi?id=665497 Signed-off-by: David Zeuthen <zeuthen@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/polkitbackend/polkitbackendactionpool.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c
index e3ed38d..0af0010 100644
--- a/src/polkitbackend/polkitbackendactionpool.c
+++ b/src/polkitbackend/polkitbackendactionpool.c
@@ -1108,7 +1108,7 @@ _localize (GHashTable *translations,
const gchar *lang)
{
const gchar *result;
- gchar lang2[256];
+ gchar **langs;
guint n;
if (lang == NULL)
@@ -1123,16 +1123,14 @@ _localize (GHashTable *translations,
goto out;
/* we could have a translation for 'da' but lang=='da_DK'; cut off the last part and try again */
- strncpy (lang2, lang, sizeof (lang2));
- for (n = 0; lang2[n] != '\0'; n++)
+ langs = g_get_locale_variants (lang);
+ for (n = 0; langs[n] != NULL; n++)
{
- if (lang2[n] == '_')
- {
- lang2[n] = '\0';
- break;
- }
+ result = (const char *) g_hash_table_lookup (translations, (void *) langs[n]);
+ if (result != NULL)
+ break;
}
- result = (const char *) g_hash_table_lookup (translations, (void *) lang2);
+ g_strfreev (langs);
if (result != NULL)
goto out;