+/*****************************************************************************
+ * SetLanguage: set the interface language.
+ *****************************************************************************
+ * We set the LC_MESSAGES locale category for interface messages and buttons,
+ * as well as the LC_CTYPE category for string sorting and possible wide
+ * character support.
+ *****************************************************************************/
+static void SetLanguage ( char const *psz_lang )
+{
+#if defined( ENABLE_NLS ) \
+ && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
+
+ char * psz_path;
+#ifdef SYS_DARWIN
+ char psz_tmp[1024];
+#endif
+
+# if defined( HAVE_INCLUDED_GETTEXT ) && !defined( HAVE_LC_MESSAGES )
+ if( *psz_lang )
+ {
+ /* We set LC_ALL manually because it is the only way to set
+ * the language at runtime under eg. Windows. Beware that this
+ * makes the environment unconsistent when libvlc is unloaded and
+ * should probably be moved to a safer place like vlc.c. */
+ static char psz_lcall[20];
+ snprintf( psz_lcall, 19, "LC_ALL=%s", psz_lang );
+ psz_lcall[19] = '\0';
+ putenv( psz_lcall );
+ }
+# endif
+
+# if defined( HAVE_LC_MESSAGES )
+ setlocale( LC_MESSAGES, psz_lang );
+# endif
+ setlocale( LC_CTYPE, psz_lang );
+
+ /* Specify where to find the locales for current domain */
+#ifndef SYS_DARWIN
+ psz_path = LOCALEDIR;
+#else
+ snprintf( psz_tmp, sizeof(psz_tmp), "%s/%s", libvlc.psz_vlcpath,
+ "locale" );
+ psz_path = psz_tmp;
+#endif
+ if( !bindtextdomain( PACKAGE, psz_path ) )
+ {
+ fprintf( stderr, "warning: no domain %s in directory %s\n",
+ PACKAGE, psz_path );
+ }
+
+ /* Set the default domain */
+ textdomain( PACKAGE );
+#endif
+}
+