diff options
Diffstat (limited to 'src/lib/nls.c')
-rw-r--r-- | src/lib/nls.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/lib/nls.c b/src/lib/nls.c index cc6f0e5f..ca57ce32 100644 --- a/src/lib/nls.c +++ b/src/lib/nls.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010, 2011 GNUnet e.V. | 3 | Copyright (C) 2010, 2011, 2021 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -17,7 +17,6 @@ | |||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file src/lib/nls.c | 21 | * @file src/lib/nls.c |
23 | * @brief natural language support | 22 | * @brief natural language support |
@@ -30,24 +29,32 @@ | |||
30 | #endif | 29 | #endif |
31 | 30 | ||
32 | 31 | ||
33 | /** | ||
34 | * Initialize GNU gettext for message translation. | ||
35 | */ | ||
36 | void | 32 | void |
37 | GNUNET_GTK_setup_nls () | 33 | GNUNET_GTK_setup_nls () |
38 | { | 34 | { |
39 | #if ENABLE_NLS | 35 | #if ENABLE_NLS |
36 | struct GNUNET_OS_ProjectData *mypd; | ||
37 | struct GNUNET_OS_ProjectData *pd; | ||
40 | char *path; | 38 | char *path; |
41 | 39 | ||
40 | pd = GNUNET_OS_project_data_get (); | ||
42 | setlocale (LC_ALL, ""); | 41 | setlocale (LC_ALL, ""); |
43 | GNUNET_asprintf (&path, | 42 | GNUNET_asprintf (&path, |
44 | "%s/%s/locale/", | 43 | "%s/%s/locale/", |
45 | GNUNET_GTK_get_data_dir (), | 44 | GNUNET_GTK_get_data_dir (), |
46 | PACKAGE_NAME); | 45 | PACKAGE_NAME); |
47 | bindtextdomain ("gnunet-gtk", path); | 46 | bindtextdomain ("gnunet-gtk", |
48 | textdomain ("gnunet-gtk"); | 47 | path); |
49 | bind_textdomain_codeset ("GNUnet", "UTF-8"); | 48 | if (NULL != pd->gettext_path) |
50 | bind_textdomain_codeset ("gnunet-gtk", "UTF-8"); | 49 | bindtextdomain (pd->gettext_domain, |
50 | pd->gettext_path); | ||
51 | textdomain (pd->gettext_domain); | ||
52 | bind_textdomain_codeset ("GNUnet", | ||
53 | "UTF-8"); | ||
54 | bind_textdomain_codeset ("gnunet-gtk", | ||
55 | "UTF-8"); | ||
56 | bind_textdomain_codeset (pd->gettext_domain, | ||
57 | "UTF-8"); | ||
51 | GNUNET_free (path); | 58 | GNUNET_free (path); |
52 | #else | 59 | #else |
53 | fprintf ( | 60 | fprintf ( |
@@ -71,20 +78,12 @@ get_filename_charset (const gchar **filename_charset) | |||
71 | gboolean is_utf8; | 78 | gboolean is_utf8; |
72 | 79 | ||
73 | is_utf8 = g_get_filename_charsets (&charsets); | 80 | is_utf8 = g_get_filename_charsets (&charsets); |
74 | |||
75 | if (filename_charset) | 81 | if (filename_charset) |
76 | *filename_charset = charsets[0]; | 82 | *filename_charset = charsets[0]; |
77 | |||
78 | return is_utf8; | 83 | return is_utf8; |
79 | } | 84 | } |
80 | 85 | ||
81 | 86 | ||
82 | /** | ||
83 | * Convert a string from the current locale to UTF-8. | ||
84 | * | ||
85 | * @param str_loc string in current locale | ||
86 | * @return string in UTF-8, NULL if str_loc was NULL | ||
87 | */ | ||
88 | char * | 87 | char * |
89 | GNUNET_GTK_from_loc_to_utf8 (const char *str_loc) | 88 | GNUNET_GTK_from_loc_to_utf8 (const char *str_loc) |
90 | { | 89 | { |
@@ -99,7 +98,9 @@ GNUNET_GTK_from_loc_to_utf8 (const char *str_loc) | |||
99 | if (is_UTF8) | 98 | if (is_UTF8) |
100 | str_utf8 = GNUNET_strdup (str_loc); | 99 | str_utf8 = GNUNET_strdup (str_loc); |
101 | else | 100 | else |
102 | str_utf8 = GNUNET_STRINGS_to_utf8 (str_loc, strlen (str_loc), loc_charset); | 101 | str_utf8 = GNUNET_STRINGS_to_utf8 (str_loc, |
102 | strlen (str_loc), | ||
103 | loc_charset); | ||
103 | return str_utf8; | 104 | return str_utf8; |
104 | } | 105 | } |
105 | 106 | ||
@@ -125,18 +126,14 @@ from_filename_to_utf8 (gchar *filename) | |||
125 | str_utf8 = GNUNET_strdup (filename); | 126 | str_utf8 = GNUNET_strdup (filename); |
126 | else | 127 | else |
127 | str_utf8 = | 128 | str_utf8 = |
128 | GNUNET_STRINGS_to_utf8 (filename, strlen (filename), filename_charset); | 129 | GNUNET_STRINGS_to_utf8 (filename, |
130 | strlen (filename), | ||
131 | filename_charset); | ||
129 | 132 | ||
130 | return str_utf8; | 133 | return str_utf8; |
131 | } | 134 | } |
132 | 135 | ||
133 | 136 | ||
134 | /** | ||
135 | * Returns filename form filechooser, encoded in UTF-8. | ||
136 | * | ||
137 | * @param fc file chooser to inspect | ||
138 | * @return selected filename as UTF-8, NULL on errors | ||
139 | */ | ||
140 | char * | 137 | char * |
141 | GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc) | 138 | GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc) |
142 | { | 139 | { |
@@ -150,4 +147,5 @@ GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc) | |||
150 | return filename_utf8; | 147 | return filename_utf8; |
151 | } | 148 | } |
152 | 149 | ||
150 | |||
153 | /* end of nls.c */ | 151 | /* end of nls.c */ |