Commit fc8cd1d9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: fix gettext with non-ASCII installation path

Note that this only works if the path can be represented in the ANSI
code page. Otherwise, you will need to patch gettext.
(cherry picked from commit 7b21f9d5490bd37f64b3aa67fce05e1a7d9b811f)
(cherry picked from commit bbcc3288fbad733a2b574efc435c32a400e872b1)
parent b5569228
...@@ -29,33 +29,44 @@ ...@@ -29,33 +29,44 @@
# include <libintl.h> # include <libintl.h>
# if defined (__APPLE__) || defined (WIN32) # if defined (__APPLE__) || defined (WIN32)
# include "config/configuration.h" # include "config/configuration.h"
# include <vlc_charset.h>
# endif # endif
#endif #endif
int vlc_bindtextdomain (const char *domain) int vlc_bindtextdomain (const char *domain)
{ {
int ret = 0;
#if defined (ENABLE_NLS) #if defined (ENABLE_NLS)
/* Specify where to find the locales for current domain */ /* Specify where to find the locales for current domain */
# if !defined (__APPLE__) && !defined (WIN32) # if !defined (__APPLE__) && !defined (WIN32)
static const char path[] = LOCALEDIR; static const char path[] = LOCALEDIR;
if (bindtextdomain (domain, path) == NULL)
{
fprintf (stderr, "%s: text domain not found in %s\n", domain, path);
return -1;
}
# else # else
char *datadir = config_GetDataDirDefault(); char *datadir = config_GetDataDirDefault();
char *path;
if (unlikely(datadir == NULL)) if (unlikely(datadir == NULL))
return -1; return -1;
ret = asprintf (&path, "%s" DIR_SEP "locale", datadir);
char *upath;
int ret = asprintf (&upath, "%s" DIR_SEP "locale", datadir);
free (datadir); free (datadir);
# endif if (unlikely(ret == -1))
return -1;
if (bindtextdomain (domain, path) == NULL) char *lpath = ToLocaleDup (upath);
if (lpath == NULL || bindtextdomain (domain, lpath) == NULL)
{ {
fprintf (stderr, "%s: text domain not found in %s\n", domain, path); free (lpath);
ret = -1; fprintf (stderr, "%s: text domain not found in %s\n", domain, upath);
goto out; free (upath);
return -1;
} }
free (lpath);
free (upath);
# endif
/* LibVLC wants all messages in UTF-8. /* LibVLC wants all messages in UTF-8.
* Unfortunately, we cannot ask UTF-8 for strerror_r(), strsignal_r() * Unfortunately, we cannot ask UTF-8 for strerror_r(), strsignal_r()
...@@ -66,24 +77,17 @@ int vlc_bindtextdomain (const char *domain) ...@@ -66,24 +77,17 @@ int vlc_bindtextdomain (const char *domain)
fprintf (stderr, "%s: UTF-8 encoding bot available\n", domain); fprintf (stderr, "%s: UTF-8 encoding bot available\n", domain);
// Unbinds the text domain to avoid broken encoding // Unbinds the text domain to avoid broken encoding
bindtextdomain (PACKAGE_NAME, "/DOES_NOT_EXIST"); bindtextdomain (PACKAGE_NAME, "/DOES_NOT_EXIST");
ret = -1; return -1;
goto out;
} }
/* LibVLC does NOT set the default textdomain, since it is a library. /* LibVLC does NOT set the default textdomain, since it is a library.
* This could otherwise break programs using LibVLC (other than VLC). * This could otherwise break programs using LibVLC (other than VLC).
* textdomain (PACKAGE_NAME); * textdomain (PACKAGE_NAME);
*/ */
out:
# if defined (__APPLE__) || defined (WIN32)
free (path);
# endif
#else /* !ENABLE_NLS */ #else /* !ENABLE_NLS */
(void)domain; (void)domain;
#endif #endif
return ret; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment