aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/os_installation.c26
-rw-r--r--src/util/program.c21
2 files changed, 39 insertions, 8 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}
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)