Reworked the code doing the blending in vout.
[vlc/vlc-skelet.git] / src / modules / textdomain.c
blob4d7e54e75fe51c217b6c47a6ef1a3b20b55f65c8
1 /*****************************************************************************
2 * textdomain.c : Modules text domain management
3 *****************************************************************************
4 * Copyright (C) 2010 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <vlc_common.h>
26 #include "modules/modules.h"
28 #ifdef ENABLE_NLS
29 # include <libintl.h>
30 # if defined (__APPLE__) || defined (WIN32)
31 # include "config/configuration.h"
32 # endif
33 #endif
35 int vlc_bindtextdomain (const char *domain)
37 int ret = 0;
39 #if defined (ENABLE_NLS)
40 /* Specify where to find the locales for current domain */
41 # if !defined (__APPLE__) && !defined (WIN32)
42 static const char path[] = LOCALEDIR;
43 # else
44 char *datadir = config_GetDataDirDefault();
45 char *path;
47 if (unlikely(datadir == NULL))
48 return -1;
49 ret = asprintf (&path, "%s" DIR_SEP "locale", datadir);
50 free (datadir);
51 # endif
53 if (bindtextdomain (domain, path) == NULL)
55 fprintf (stderr, "%s: text domain not found in %s\n", domain, path);
56 ret = -1;
57 goto out;
60 /* LibVLC wants all messages in UTF-8.
61 * Unfortunately, we cannot ask UTF-8 for strerror_r(), strsignal_r()
62 * and other functions that are not part of our text domain.
64 if (bind_textdomain_codeset (PACKAGE_NAME, "UTF-8") == NULL)
66 fprintf (stderr, "%s: UTF-8 encoding bot available\n", domain);
67 // Unbinds the text domain to avoid broken encoding
68 bindtextdomain (PACKAGE_NAME, "/DOES_NOT_EXIST");
69 ret = -1;
70 goto out;
73 /* LibVLC does NOT set the default textdomain, since it is a library.
74 * This could otherwise break programs using LibVLC (other than VLC).
75 * textdomain (PACKAGE_NAME);
77 out:
78 # if defined (__APPLE__) || defined (WIN32)
79 free (path);
80 # endif
82 #else /* !ENABLE_NLS */
83 (void)domain;
84 #endif
86 return ret;