aboutsummaryrefslogtreecommitdiff
path: root/src/util/program.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/program.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/program.c')
-rw-r--r--src/util/program.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/util/program.c b/src/util/program.c
index 1462a03a8..73beb8d57 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -200,14 +200,19 @@ GNUNET_PROGRAM_run2 (int argc,
200 cc.cfg = cfg = GNUNET_CONFIGURATION_create (); 200 cc.cfg = cfg = GNUNET_CONFIGURATION_create ();
201 /* prepare */ 201 /* prepare */
202#if ENABLE_NLS 202#if ENABLE_NLS
203 setlocale (LC_ALL, ""); 203 if (NULL != pd->gettext_domain)
204 path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR); 204 {
205 if (NULL != path) 205 setlocale (LC_ALL, "");
206 { 206 path = (NULL == pd->gettext_path)
207 BINDTEXTDOMAIN ("GNUnet", path); 207 ? GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR)
208 GNUNET_free (path); 208 : GNUNET_strdup (pd->gettext_path);
209 } 209 if (NULL != path)
210 textdomain ("GNUnet"); 210 {
211 BINDTEXTDOMAIN (pd->gettext_domain, path);
212 GNUNET_free (path);
213 }
214 textdomain (pd->gettext_domain);
215 }
211#endif 216#endif
212 cnt = 0; 217 cnt = 0;
213 while (NULL != options[cnt].name) 218 while (NULL != options[cnt].name)