git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Bug report] Git incorrectly selects language in macos

From
Nate Weaver <wevah@derailer.org>
Date
Jan 15, 2019, 16:43 UTC
Message-ID
<89DD4C7B-7F8B-42C5-81F2-F14D5B2D4CFD@derailer.org>
In-Reply-To
<BF7AD597-5C05-4A7A-8DB6-0FEA2F95AF72@derailer.org>
Show 35 quoted lines
> On Jan 15, 2019, at 09:35:52, Nate Weaver <wevah@derailer.org> wrote:
> 
>> On Sep 16, 2018, at 02:15:33, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> 
>> On Fri, Sep 14, 2018 at 10:20 PM Niko Dzhus <primenico@gmail.com> wrote:
>>> Looks like the issue appeared after updating git from brew.
>>> 
>>> A quick search revealed that brew changed how it builds git recently.
>>> I think, it just didn't include i18n by default before, so I never
>>> noticed this.
>>> 
>>> Anybody here familiar enough with the build process and dependencies
>>> of git to pinpoint what exactly is causing this and how to fix it?...
>> 
>> This problem is not specific to Git. Earlier in the thread, Ævar
>> asked[1] if the problem also occurs with other command-line programs,
>> and indeed it does. For instance, I tried with 'wget' installed via
>> brew, and it exhibits the same odd behavior. Ævar suggested that there
>> might be some magic special-casing English, which makes me wonder if
>> brew builds such magic into gettext(?) or if the magic is part of
>> MacOS itself.
>> 
>> [1]: https://public-inbox.org/git/87a7ojlp31.fsf@evledraar.gmail.com/
> 
> I discovered that moving/renaming /usr/local/share/locale made this
> issue go away for me. While 'de' and 'fr' have a git.mo file in their
> LC_MESSAGES subdirectory, there is no 'en' directory.
> 
> If I copy the 'fr' version to a newly-created 'en' directory, then all my
> git output is in French; my language order in System Preferences is
> English (US) -> German -> Japanese.
> 
> Not sure if this is gettext's or macOS's issue.
> 
> --Nate Weaver (Wevah)

Upon further digging, this is an issue in gettext's code on macOS: The function _nl_language_preferences_default (in langprefs.c) specifically breaks early when it sees the literal string "en" in the list (from the "AppleLanguages" defaults key), but not when it gets "en-US", etc.

I.e., it doesn't check for a prefix.

This can be fixed (though there might be a better way) simply by replacing both instances of

if (strcmp (buf, "en") == 0)
with
if (strncmp (buf, "en", 2) == 0)
in gettext's langprefs.c.
Previous: Nate WeaverNext: Nate Weaver
Message 7 of 11 in “[Bug report] Git incorrectly selects language in macos”
  1. Niko DzhusSep 14, 2018
  2. Ævar Arnfjörð BjarmasonSep 14, 2018
  3. Niko DzhusSep 15, 2018
  4. Niko DzhusSep 15, 2018
  5. Eric SunshineSep 16, 2018
  6. Nate WeaverJan 15, 2019
  7. Nate WeaverJan 15, 2019
  8. Nate WeaverJan 15, 2019
  9. Eric SunshineJan 15, 2019
  10. Jonathan NiederJan 16, 2019
  11. Jonathan NiederJan 16, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.