# problem with setlocale trick in gettext.c

2 messages from 2012-09-24 to 2012-09-25. Participants: Nguyen Thai Ngoc Duy, Junio C Hamano.
Thread: https://gitlist.dev/t/31634

## Nguyen Thai Ngoc Duy, 2012-09-24 14:08

Subject: problem with setlocale trick in gettext.c
Message-ID: <CACsJy8A+YvdGc6LM5baFqHoB91p6TAjQ9kKXuaPspvL--mfe0Q@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8A%2BYvdGc6LM5baFqHoB91p6TAjQ9kKXuaPspvL--mfe0Q%40mail.gmail.com

```
Hi,

I think the setlocale() trick in init_gettext_charset() messes up
locale support from library. Currently I get

fatal: Could not switch to '/foo/': Kh?ng c? t?p tin ho?c th? m?c nh? v?y

The question marks are what I actually see. The point here is to call
strerrno(), which should return a l10n string. With this patch

diff --git a/gettext.c b/gettext.c
index 71e9545..eeb88c5 100644
--- a/gettext.c
+++ b/gettext.c
@@ -115,7 +115,7 @@ static void init_gettext_charset(const char *domain)
        setlocale(LC_CTYPE, "");
        charset = locale_charset();
        bind_textdomain_codeset(domain, charset);
-       setlocale(LC_CTYPE, "C");
+       //setlocale(LC_CTYPE, "C");
 }

 void git_setup_gettext(void)

I get correct output again

fatal: Could not switch to '/foo/': Không có tập tin hoặc thư mục như vậy

Anybody knows how this happens?
-- 
Duy

```

## Junio C Hamano, 2012-09-25 17:31

Subject: Re: problem with setlocale trick in gettext.c
Message-ID: <7va9wevwjr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7va9wevwjr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CACsJy8A+YvdGc6LM5baFqHoB91p6TAjQ9kKXuaPspvL--mfe0Q@mail.gmail.com>

```
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:

> I think the setlocale() trick in init_gettext_charset() messes up
> locale support from library. Currently I get
>
> fatal: Could not switch to '/foo/': Kh?ng c? t?p tin ho?c th? m?c nh? v?y

That pretty much matches what the big comment before your patch
disables, doesn't it?  Could it be that newer/older libc differ
in the behaviour around this code?

```
