summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorWu Xiaotian <[email protected]>2019-06-09 21:57:54 +0800
committerraveit65 <[email protected]>2019-06-11 16:06:41 +0200
commit967ea267f537dfeb9a3e8eb8169899ac199e50d9 (patch)
tree695647125d10e1b6e7872c1cb5fb9cbfff1145a1 /libmate-desktop
parent451baa964b34accd93af19ab8c6aa93636bf79fd (diff)
downloadmate-desktop-967ea267f537dfeb9a3e8eb8169899ac199e50d9.tar.bz2
mate-desktop-967ea267f537dfeb9a3e8eb8169899ac199e50d9.tar.xz
check both {$prefix,/usr}/share/locale dirs for translation
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/mate-languages.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/libmate-desktop/mate-languages.c b/libmate-desktop/mate-languages.c
index 865c5ca..f6a4ff6 100644
--- a/libmate-desktop/mate-languages.c
+++ b/libmate-desktop/mate-languages.c
@@ -325,25 +325,12 @@ language_name_get_codeset_details (const char *language_name,
setlocale (LC_CTYPE, old_locale);
}
-/**
- * mate_language_has_translations:
- * @code: an ISO 639 code string
- *
- * Returns %TRUE if there are translations for language @code.
- *
- * Return value: %TRUE if there are translations for language @code.
- *
- * Since: 1.22
- */
-gboolean
-mate_language_has_translations (const char *code)
+static gboolean
+locale_dir_has_mo_files (const gchar* path)
{
GDir *dir;
const char *name;
gboolean has_translations;
- g_autofree char *path = NULL;
-
- path = g_build_filename (MATELOCALEDIR, code, "LC_MESSAGES", NULL);
has_translations = FALSE;
dir = g_dir_open (path, 0, NULL);
@@ -370,6 +357,35 @@ mate_language_has_translations (const char *code)
return has_translations;
}
+/**
+ * mate_language_has_translations:
+ * @code: an ISO 639 code string
+ *
+ * Returns %TRUE if there are translations for language @code.
+ *
+ * Return value: %TRUE if there are translations for language @code.
+ *
+ * Since: 1.22
+ */
+gboolean
+mate_language_has_translations (const char *code)
+{
+ gboolean has_translations;
+ gchar *path = NULL;
+
+ 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);
+ }
+
+ g_free(path);
+ return has_translations;
+}
+
static gboolean
add_locale (const char *language_name,
gboolean utf8_only)