From 5897ddd7ef40a88f1844137fec09ffe7eb3f86ea Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 30 Jun 2016 11:41:12 +0200 Subject: [PATCH] utils: Add flatpak_get_current_locale_subpaths() --- common/flatpak-utils.c | 33 +++++++++++++++++++++++++++++++++ common/flatpak-utils.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index 1ccedcd7..102edbed 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -3499,3 +3499,36 @@ flatpak_completion_free (FlatpakCompletion *completion) g_strfreev (completion->original_argv); g_free (completion); } + +char ** +flatpak_get_current_locale_subpaths (void) +{ + const gchar * const *langs = g_get_language_names (); + GPtrArray *subpaths = g_ptr_array_new (); + int i; + + for (i = 0; langs[i] != NULL; i++) + { + g_autofree char *dir = g_strconcat ("/", langs[i], NULL); + char *c; + + c = strchr (dir, '@'); + if (c != NULL) + *c = 0; + c = strchr (dir, '_'); + if (c != NULL) + *c = 0; + c = strchr (dir, '.'); + if (c != NULL) + *c = 0; + + if (strcmp (dir, "/C") == 0) + continue; + + g_ptr_array_add (subpaths, g_steal_pointer (&dir)); + } + + g_ptr_array_add (subpaths, NULL); + + return (char **)g_ptr_array_free (subpaths, FALSE); +} diff --git a/common/flatpak-utils.h b/common/flatpak-utils.h index 7b124ebd..ed6a87cd 100644 --- a/common/flatpak-utils.h +++ b/common/flatpak-utils.h @@ -46,6 +46,8 @@ const char ** flatpak_get_arches (void); const char * flatpak_get_bwrap (void); +char ** flatpak_get_current_locale_subpaths (void); + void flatpak_migrate_from_xdg_app (void); GBytes * flatpak_read_stream (GInputStream *in,