aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_os_lib.h12
-rw-r--r--src/include/platform.h2
-rw-r--r--src/util/os_installation.c26
-rw-r--r--src/util/program.c21
4 files changed, 52 insertions, 9 deletions
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index d43711a99..b632ab262 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -276,6 +276,18 @@ struct GNUNET_OS_ProjectData
276 * Non-zero means this project is part of GNU. 276 * Non-zero means this project is part of GNU.
277 */ 277 */
278 int is_gnu; 278 int is_gnu;
279
280 /**
281 * Gettext domain for localisation, e.g. the PACKAGE macro.
282 * Setting this field to NULL disables gettext.
283 */
284 char *gettext_domain;
285
286 /**
287 * Gettext directory, e.g. the LOCALEDIR macro.
288 * If this field is NULL, the path is automatically inferred.
289 */
290 char *gettext_path;
279}; 291};
280 292
281 293
diff --git a/src/include/platform.h b/src/include/platform.h
index 4636ddd73..0e3144ee8 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -205,7 +205,7 @@
205/** 205/**
206 * GNU gettext support macro. 206 * GNU gettext support macro.
207 */ 207 */
208#define _(String) dgettext("gnunet",String) 208#define _(String) dgettext(PACKAGE,String)
209#define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor" 209#define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
210#else 210#else
211#include "libintlemu.h" 211#include "libintlemu.h"
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}
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)