aboutsummaryrefslogtreecommitdiff
path: root/src/util/os_installation.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-09-01 13:25:07 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-09-01 13:25:07 +0200
commit3cca0d1e32fcc78707e8a8740c81048f7fc21f5c (patch)
tree54e817daa341ae6328329435d5b560b787216898 /src/util/os_installation.c
parentd86e03829d9c7c646777178cd9c082fd795fef06 (diff)
downloadgnunet-3cca0d1e32fcc78707e8a8740c81048f7fc21f5c.tar.gz
gnunet-3cca0d1e32fcc78707e8a8740c81048f7fc21f5c.zip
Added patch by AV from ML:
Currently, gettext doesn't work for out-of-tree applications. This is because GNUnet forcibly set the text domain to "GNUnet" (which apparently is also incorrect), so applications can't be localized unless their localizations are distributed in-tree by GNUnet itself. The attached patch tries to fix this by adding two more fields to GNUNET_OS_ProjectData: one field is the gettext domain of the application. As the documentation says, if it's NULL gettext is disabled so that applications can use their preferred localization method without having gettext interfering; the other field is essentially the locale directory, so applications can specify a different path if they want to, instead of having GNUnet infer it for them. Because some GNUnet libraries also use gettext internally (the util lib is a prominent example), gettext has to be initialized before the application takes over. I placed such initialization in `GNUNET_OS_init' and `GNUNET_OS_project_data_get' because those are two functions which are very likely to be called (especially the second one, since it's used in `GNUNET_PROGRAM_run2'.) If there is a better place (or some places where this is not enough) I can change it and resubmit it for review. I also changed gnunet-ext to keep it consitent with the patch. In particular, it adds a header which is required for a successful compilation, so you might want to at least make that change. Thank you, A.V. P.S. I'm still not subscribed to the list... yet.
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r--src/util/os_installation.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 9dcfa5ef1..f51bfd287 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -64,6 +64,9 @@ static const struct GNUNET_OS_ProjectData default_pd = {
64 .homepage = "http://www.gnu.org/s/gnunet/", 64 .homepage = "http://www.gnu.org/s/gnunet/",
65 .config_file = "gnunet.conf", 65 .config_file = "gnunet.conf",
66 .user_config_file = "~/.config/gnunet.conf", 66 .user_config_file = "~/.config/gnunet.conf",
67 .is_gnu = 1,
68 .gettext_domain = PACKAGE,
69 .gettext_path = NULL,
67}; 70};
68 71
69/** 72/**
@@ -73,6 +76,13 @@ static const struct GNUNET_OS_ProjectData default_pd = {
73static const struct GNUNET_OS_ProjectData *current_pd = &default_pd; 76static const struct GNUNET_OS_ProjectData *current_pd = &default_pd;
74 77
75/** 78/**
79 * Wether or not gettext has been initialized for the library.
80 * Note that the gettext initialization done within
81 * GNUNET_PROGRAM_run2 is for the specific application.
82 */
83static int gettextinit = 0;
84
85/**
76 * Return default project data used by 'libgnunetutil' for GNUnet. 86 * Return default project data used by 'libgnunetutil' for GNUnet.
77 */ 87 */
78const struct GNUNET_OS_ProjectData * 88const struct GNUNET_OS_ProjectData *
@@ -88,6 +98,14 @@ GNUNET_OS_project_data_default (void)
88const struct GNUNET_OS_ProjectData * 98const struct GNUNET_OS_ProjectData *
89GNUNET_OS_project_data_get () 99GNUNET_OS_project_data_get ()
90{ 100{
101 if (0 == gettextinit)
102 {
103 char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
104 if (NULL != path)
105 BINDTEXTDOMAIN (PACKAGE, path);
106 GNUNET_free(path);
107 gettextinit = 1;
108 }
91 return current_pd; 109 return current_pd;
92} 110}
93 111
@@ -100,6 +118,14 @@ GNUNET_OS_project_data_get ()
100void 118void
101GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd) 119GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd)
102{ 120{
121 if (0 == gettextinit)
122 {
123 char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
124 if (NULL != path)
125 BINDTEXTDOMAIN (PACKAGE, path);
126 GNUNET_free(path);
127 gettextinit = 1;
128 }
103 GNUNET_assert (NULL != pd); 129 GNUNET_assert (NULL != pd);
104 current_pd = pd; 130 current_pd = pd;
105} 131}