[gnome-initial-setup/wip/pwithnall/misc-fixes: 37/70] language: allow to specify initial languages from vendor.conf
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/pwithnall/misc-fixes: 37/70] language: allow to specify initial languages from vendor.conf
- Date: Fri, 11 Sep 2020 13:29:13 +0000 (UTC)
commit a0d23f19770193d3c58f2451a4be6df8fc34957d
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Wed Aug 16 18:51:26 2017 -0700
language: allow to specify initial languages from vendor.conf
Instead of hardcoding the initial list, we can use vendor.conf to seed
it; we still use the hardcoded defaults when that's not the case.
https://phabricator.endlessm.com/T17467
gnome-initial-setup/cc-common-language.c | 54 +++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/gnome-initial-setup/cc-common-language.c b/gnome-initial-setup/cc-common-language.c
index 0aba41f8..b925317a 100644
--- a/gnome-initial-setup/cc-common-language.c
+++ b/gnome-initial-setup/cc-common-language.c
@@ -34,6 +34,8 @@
#include "cc-common-language.h"
+#include "gnome-initial-setup.h"
+
static char *get_lang_for_user_object_path (const char *path);
static char *current_language;
@@ -288,13 +290,46 @@ insert_user_languages (GHashTable *ht)
}
}
-GHashTable *
-cc_common_language_get_initial_languages (void)
+#define VENDOR_LANGUAGE_GROUP "Language"
+#define VENDOR_LANGUAGE_INITIAL_LANGUAGES_KEY "initial_languages"
+
+static gboolean
+insert_vendor_languages (GHashTable *ht)
{
- GHashTable *ht;
+ g_autoptr(GKeyFile) keyfile = NULL;
+ g_autoptr(GError) error = NULL;
+ g_auto(GStrv) languages = NULL;
+ int idx;
+ GisDriver *driver;
+
+ /* This code will look for options under the "Language" group, and
+ * supports the following keys:
+ * - initial_languages (optional): a string list of language codes to
+ * pre-populate the initial list of languages
+ *
+ * For example, this is how this file would look on a vendor image defining
+ * a south-east Asian initial language list:
+ *
+ * [Language]
+ * initial_languages=id_ID.UTF-8;th_TH.UTF-8;vi_VN.UTF-8;hi_IN.UTF-8
+ */
+ driver = GIS_DRIVER (g_application_get_default ());
+ languages = gis_driver_conf_get_string_list (driver,
+ VENDOR_LANGUAGE_GROUP,
+ VENDOR_LANGUAGE_INITIAL_LANGUAGES_KEY,
+ NULL);
+ if (languages == NULL)
+ return FALSE;
- ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ for (idx = 0; languages[idx] != NULL; idx++)
+ insert_language (ht, languages[idx]);
+
+ return TRUE;
+}
+static void
+insert_default_languages (GHashTable *ht)
+{
insert_language (ht, "en_US.UTF-8");
#if 0
/* Having 9 languages in the list initially makes the window
@@ -311,6 +346,17 @@ cc_common_language_get_initial_languages (void)
insert_language (ht, "ja_JP.UTF-8");
insert_language (ht, "ru_RU.UTF-8");
insert_language (ht, "ar_EG.UTF-8");
+}
+
+GHashTable *
+cc_common_language_get_initial_languages (void)
+{
+ GHashTable *ht;
+
+ ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ if (!insert_vendor_languages (ht))
+ insert_default_languages (ht);
insert_user_languages (ht);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]