[MPlayer-dev-eng] [PATCH] localize with gettext (libintl)

Rich Felker dalias at aerifal.cx
Thu Nov 30 01:26:52 CET 2006


On Thu, Nov 30, 2006 at 12:52:35AM +0100, Ötvös Attila wrote:
> 2006. november 29. 23.50 dátummal Reimar Döffinger ezt írta:
> > You cannot - I emphasize - you _can not_ use setlocale, it breaks the
> > behaviour of all kinds of C library functions, most notably strcasecmp,
> > in a way that e.g. causes crashes if the locale is tr_TR. In addition it is
> > not thread-safe, so that setting it every time you need it and restoring
> > it again is at least risk and quite likely to cause problems, too (yes,
> > indirectly through libavcodec even MPlayer uses threads!).
> 
> My question: 
> 
> This is good idea:

No, anything with gettext is a very very bad idea.

> mp_msg_init()
> ...
> setlocale(LC_MESSAGES,"");	// set lc_messages
> setlocale(LC_TYPE,"");		// locale character ...
> bindtextdomain("mplayer","/usr/share/locale");
> bind_textdomain_codeset("mplayer",nl_langinfo(CODESET));
> textdomain("mplayer");
> setlocale(LC_TYPE,"C");		// locale default
> 
> I quicly probe with LC_ALL=tr_TR so work 
> (without setlocale(LC_TYPE,"C") don't work).

Changing the locale after binding the gettext domain probably results
in undefined (or at least incorrect) behavior. Regardless I'm STRONGLY
against gettext. It's one of the GNU abominations on par with
autoshit, glibc, etc.

Rich




More information about the MPlayer-dev-eng mailing list