From 459f2ae98df179bd4f466805c3af3d7c82ad09f0 Mon Sep 17 00:00:00 2001 From: rbuj Date: Wed, 29 Jul 2020 10:31:14 +0200 Subject: mate-languages: portability of localedir fallback --- libmate-desktop/mate-languages.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'libmate-desktop/mate-languages.c') diff --git a/libmate-desktop/mate-languages.c b/libmate-desktop/mate-languages.c index f6a4ff6..57ce6ab 100644 --- a/libmate-desktop/mate-languages.c +++ b/libmate-desktop/mate-languages.c @@ -370,19 +370,26 @@ locale_dir_has_mo_files (const gchar* path) gboolean mate_language_has_translations (const char *code) { - gboolean has_translations; - gchar *path = NULL; + gboolean has_translations; + gchar *path; path = g_build_filename (MATELOCALEDIR, code, "LC_MESSAGES", NULL); has_translations = locale_dir_has_mo_files (path); if (!has_translations) { - g_free(path); - path = g_build_filename ("/usr/share/locale", code, "LC_MESSAGES", NULL); - has_translations = locale_dir_has_mo_files (path); + const char * const *system_data_dirs; + int i = 0; + + system_data_dirs = g_get_system_data_dirs (); + while ((system_data_dirs[i] != NULL) && (has_translations == FALSE)) { + g_free (path); + path = g_build_filename (system_data_dirs[i], "locale", code, "LC_MESSAGES", NULL); + has_translations = locale_dir_has_mo_files (path); + ++i; + } } - g_free(path); + g_free (path); return has_translations; } -- cgit v1.2.1