Re: gettext implementation for glib



On 3 Aug 2001, Havoc Pennington wrote:

 Hi, 
> 
> Sven Neumann <sven gimp org> writes:
> > Hi,
> > 
> > Alex Larsson <alexl redhat com> writes:
> > 
> > > +static const char *
> > > +get_locale (void)
> > > +{
> > > +  const char *locale;
> > > +  
> > > +  locale = g_getenv ("LANG");
> > > +  if (locale)
> > > +    return locale;
> > > +
> > > +  return "en_US";
> >              ^^^^^ 
> > I'm not sure, but shouldn't that return "C" ?!
> 
> I think it should just call setlocale() to get the locale, instead of
> trying to guess. ;-)


 Hi, 

 It should use setlocale(LC_MESSAGES,NULL) to get the name of locale to
use for messages instead of getting the $LANG directly. As I understand, NULL
can't be returned by it.("C" in the worst case AFAIK). User may want to see
messages in one language while having ability to work with other language.

 The correct method of getting charset is

#ifdef HAVE_LANGINFO_H /* exteng 'configure' script to detect presence */
#include <langinfo.h>
#endif


#ifdef _NL_CTYPE_CODESET_NAME
        charset = nl_langinfo (_NL_CTYPE_CODESET_NAME);
#elif defined(CODESET)
        charset = nl_langinfo (CODESET);
#elif
        {
                char* locale = setlocale(LC_CTYPE,NULL);
                char* tmp = strchr(locale,'.');
                if (tmp)
                        charset = tmp+1;
        }
#endif

 But for gtk2.0 it should always be
	charset = "utf8";
 independant of correct ways of getting charset since gtk allows to use only
utf8 strings.
 
 Best regards,
  -Vlad





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]