{"thread":{"id":"49348","subject":"[Bug report] Git incorrectly selects language in macos","startedAt":"2018-09-14T19:08:20Z","lastAt":"2019-01-16T02:28:14Z","messageCount":11,"participants":["Niko Dzhus","Ævar Arnfjörð Bjarmason","Eric Sunshine","Nate Weaver","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"358151","messageId":"CAKd-JgStGb4Ka9Rs6G2e4ADQKZVrsJMsNGz1sRP_4Ej4=FtxtA@mail.gmail.com","threadId":"49348","inReplyTo":null,"subject":"[Bug report] Git incorrectly selects language in macos","fromName":"Niko Dzhus","fromEmail":"primenico@gmail.com","sentAt":"2018-09-14T19:08:07Z","receivedAt":"2018-09-14T19:08:20Z","isPatch":false,"sender":{"key":"primenico@gmail.com","avatar":null},"body":"It doesn't use English when other language is available as a secondary language.\n\nReproducing:\n\n1. Open \"Language & Region\" in macos settings\n2. In \"Preferred languages\" box, set English as a primary language.\n3. Add another language, that git is translated to, as a secondary\nlanguage, for example, French or German.\n4. Run any git command - git will use the secondary language, instead\nof English.\n\nWhen the secondary language is removed, then git starts using English again.\n\nI have git 2.19.0, installed from brew, and my OS is macOS 10.13.6 .\n"},{"id":"358166","messageId":"87a7ojlp31.fsf@evledraar.gmail.com","threadId":"49348","inReplyTo":"CAKd-JgStGb4Ka9Rs6G2e4ADQKZVrsJMsNGz1sRP_4Ej4=FtxtA@mail.gmail.com","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-09-14T21:57:22Z","receivedAt":"2018-09-14T21:57:32Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Sep 14 2018, Niko Dzhus wrote:\n\n> It doesn't use English when other language is available as a secondary language.\n>\n> Reproducing:\n>\n> 1. Open \"Language & Region\" in macos settings\n> 2. In \"Preferred languages\" box, set English as a primary language.\n> 3. Add another language, that git is translated to, as a secondary\n> language, for example, French or German.\n> 4. Run any git command - git will use the secondary language, instead\n> of English.\n>\n> When the secondary language is removed, then git starts using English again.\n>\n> I have git 2.19.0, installed from brew, and my OS is macOS 10.13.6 .\n\nWhat's the output of these two commands for you:\n\n 1. locale\n 2. env | grep -e LC -e LANG\n\nWe don't do any such magic ourselves, so whatever this is is down to how\ni18n in general works on your system, do you have any other translated\ncommand-line program that works differently?\n\nI suspect there's some DWYM logic here that always treats English as a\nsecondary language.\n\nDo you also e.g. get the same results if you select say Swedish as a\nprimary language and German as a secondary? I.e. a Git in German, as\nopposed to Swedish?\n"},{"id":"358177","messageId":"CAKd-JgRgrJXNVyxsD-cg-TJsXu0K35tv5cSDjbsYNXCiu1j0hg@mail.gmail.com","threadId":"49348","inReplyTo":"87a7ojlp31.fsf@evledraar.gmail.com","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Niko Dzhus","fromEmail":"primenico@gmail.com","sentAt":"2018-09-15T00:51:17Z","receivedAt":"2018-09-15T00:52:26Z","isPatch":false,"sender":{"key":"primenico@gmail.com","avatar":null},"body":"Tried what you suggested - it seems, it only ignores English. In you\nexample, with Swedish as primary and German as secondary, git uses\nSwedish.\n\nWith more that one secondary language, the one with a higher priority\nis being used, as expected. I also tried using non-generic English\n(English-UK and English-US), but they also get ignored.\n\nTerminal commands return the following:\n\n➜  ~ locale\nLANG=\nLC_COLLATE=\"C\"\nLC_CTYPE=\"UTF-8\"\nLC_MESSAGES=\"C\"\nLC_MONETARY=\"C\"\nLC_NUMERIC=\"C\"\nLC_TIME=\"C\"\nLC_ALL=\n➜  ~ env | grep -e LC -e LANG\nLC_CTYPE=UTF-8\n➜  ~\n\nIt doesn't change with primary/secondary language switching. I don't\nhave any manual overrides in my .zshrc and .zprofile for those\nneither.\n\nOn Sat, Sep 15, 2018 at 12:57 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>\n>\n> On Fri, Sep 14 2018, Niko Dzhus wrote:\n>\n> > It doesn't use English when other language is available as a secondary language.\n> >\n> > Reproducing:\n> >\n> > 1. Open \"Language & Region\" in macos settings\n> > 2. In \"Preferred languages\" box, set English as a primary language.\n> > 3. Add another language, that git is translated to, as a secondary\n> > language, for example, French or German.\n> > 4. Run any git command - git will use the secondary language, instead\n> > of English.\n> >\n> > When the secondary language is removed, then git starts using English again.\n> >\n> > I have git 2.19.0, installed from brew, and my OS is macOS 10.13.6 .\n>\n> What's the output of these two commands for you:\n>\n>  1. locale\n>  2. env | grep -e LC -e LANG\n>\n> We don't do any such magic ourselves, so whatever this is is down to how\n> i18n in general works on your system, do you have any other translated\n> command-line program that works differently?\n>\n> I suspect there's some DWYM logic here that always treats English as a\n> secondary language.\n>\n> Do you also e.g. get the same results if you select say Swedish as a\n> primary language and German as a secondary? I.e. a Git in German, as\n> opposed to Swedish?\n"},{"id":"358179","messageId":"CAKd-JgS3omKbN+OzQL2dUun6Seg9CjDNk8KEj9m83xdTZE=7FA@mail.gmail.com","threadId":"49348","inReplyTo":"CAKd-JgStGb4Ka9Rs6G2e4ADQKZVrsJMsNGz1sRP_4Ej4=FtxtA@mail.gmail.com","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Niko Dzhus","fromEmail":"primenico@gmail.com","sentAt":"2018-09-15T02:20:32Z","receivedAt":"2018-09-15T02:20:46Z","isPatch":false,"sender":{"key":"primenico@gmail.com","avatar":null},"body":"Looks like the issue appeared after updating git from brew.\n\nI tried it on a different mac laptop, git 2.18 still used English, but\nafter updating to 2.19 it started using secondary language.\n\nA quick search revealed that brew changed how it builds git recently.\nI think, it just didn't include i18n by default before, so I never\nnoticed this.\nHere's the history of formula changes:\nhttps://github.com/Homebrew/homebrew-core/commits/master/Formula/git.rb\nAlso, I found this thread https://github.com/Homebrew/homebrew-core/issues/31980\n\nAnybody here familiar enough with the build process and dependencies\nof git to pinpoint what exactly is causing this and how to fix it?...\n\nOn Fri, Sep 14, 2018 at 10:08 PM Niko Dzhus <primenico@gmail.com> wrote:\n>\n> It doesn't use English when other language is available as a secondary language.\n>\n> Reproducing:\n>\n> 1. Open \"Language & Region\" in macos settings\n> 2. In \"Preferred languages\" box, set English as a primary language.\n> 3. Add another language, that git is translated to, as a secondary\n> language, for example, French or German.\n> 4. Run any git command - git will use the secondary language, instead\n> of English.\n>\n> When the secondary language is removed, then git starts using English again.\n>\n> I have git 2.19.0, installed from brew, and my OS is macOS 10.13.6 .\n"},{"id":"358224","messageId":"CAPig+cQWW9kibWYKu5oRDgo_Pt4wVmzkqzbTG=YGvwqRCXcNXw@mail.gmail.com","threadId":"49348","inReplyTo":"CAKd-JgS3omKbN+OzQL2dUun6Seg9CjDNk8KEj9m83xdTZE=7FA@mail.gmail.com","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-09-16T07:15:33Z","receivedAt":"2018-09-16T07:15:47Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Sep 14, 2018 at 10:20 PM Niko Dzhus <primenico@gmail.com> wrote:\n> Looks like the issue appeared after updating git from brew.\n>\n> A quick search revealed that brew changed how it builds git recently.\n> I think, it just didn't include i18n by default before, so I never\n> noticed this.\n>\n> Anybody here familiar enough with the build process and dependencies\n> of git to pinpoint what exactly is causing this and how to fix it?...\n\nThis problem is not specific to Git. Earlier in the thread, Ævar\nasked[1] if the problem also occurs with other command-line programs,\nand indeed it does. For instance, I tried with 'wget' installed via\nbrew, and it exhibits the same odd behavior. Ævar suggested that there\nmight be some magic special-casing English, which makes me wonder if\nbrew builds such magic into gettext(?) or if the magic is part of\nMacOS itself.\n\n[1]: https://public-inbox.org/git/87a7ojlp31.fsf@evledraar.gmail.com/\n"},{"id":"366720","messageId":"BF7AD597-5C05-4A7A-8DB6-0FEA2F95AF72@derailer.org","threadId":"49348","inReplyTo":"CAPig+cQWW9kibWYKu5oRDgo_Pt4wVmzkqzbTG=YGvwqRCXcNXw@mail.gmail.com","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Nate Weaver","fromEmail":"wevah@derailer.org","sentAt":"2019-01-15T15:35:52Z","receivedAt":"2019-01-15T15:43:34Z","isPatch":false,"sender":{"key":"wevah@derailer.org","avatar":"https://gravatar.com/avatar/46b0edf1785181a23e8b6ff26b92d719ebda2e5445bb6c492fac8e65a3751560?d=mp&s=160"},"body":"> On Sep 16, 2018, at 02:15:33, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> \n> On Fri, Sep 14, 2018 at 10:20 PM Niko Dzhus <primenico@gmail.com> wrote:\n>> Looks like the issue appeared after updating git from brew.\n>> \n>> A quick search revealed that brew changed how it builds git recently.\n>> I think, it just didn't include i18n by default before, so I never\n>> noticed this.\n>> \n>> Anybody here familiar enough with the build process and dependencies\n>> of git to pinpoint what exactly is causing this and how to fix it?...\n> \n> This problem is not specific to Git. Earlier in the thread, Ævar\n> asked[1] if the problem also occurs with other command-line programs,\n> and indeed it does. For instance, I tried with 'wget' installed via\n> brew, and it exhibits the same odd behavior. Ævar suggested that there\n> might be some magic special-casing English, which makes me wonder if\n> brew builds such magic into gettext(?) or if the magic is part of\n> MacOS itself.\n> \n> [1]: https://public-inbox.org/git/87a7ojlp31.fsf@evledraar.gmail.com/\n\nI discovered that moving/renaming /usr/local/share/locale made this\nissue go away for me. While 'de' and 'fr' have a git.mo file in their\nLC_MESSAGES subdirectory, there is no 'en' directory.\n\nIf I copy the 'fr' version to a newly-created 'en' directory, then all my\ngit output is in French; my language order in System Preferences is\nEnglish (US) -> German -> Japanese.\n\nNot sure if this is gettext's or macOS's issue.\n\n--Nate Weaver (Wevah)\n"},{"id":"366723","messageId":"89DD4C7B-7F8B-42C5-81F2-F14D5B2D4CFD@derailer.org","threadId":"49348","inReplyTo":"BF7AD597-5C05-4A7A-8DB6-0FEA2F95AF72@derailer.org","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Nate Weaver","fromEmail":"wevah@derailer.org","sentAt":"2019-01-15T16:43:48Z","receivedAt":"2019-01-15T16:53:13Z","isPatch":false,"sender":{"key":"wevah@derailer.org","avatar":"https://gravatar.com/avatar/46b0edf1785181a23e8b6ff26b92d719ebda2e5445bb6c492fac8e65a3751560?d=mp&s=160"},"body":"> On Jan 15, 2019, at 09:35:52, Nate Weaver <wevah@derailer.org> wrote:\n> \n>> On Sep 16, 2018, at 02:15:33, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> \n>> On Fri, Sep 14, 2018 at 10:20 PM Niko Dzhus <primenico@gmail.com> wrote:\n>>> Looks like the issue appeared after updating git from brew.\n>>> \n>>> A quick search revealed that brew changed how it builds git recently.\n>>> I think, it just didn't include i18n by default before, so I never\n>>> noticed this.\n>>> \n>>> Anybody here familiar enough with the build process and dependencies\n>>> of git to pinpoint what exactly is causing this and how to fix it?...\n>> \n>> This problem is not specific to Git. Earlier in the thread, Ævar\n>> asked[1] if the problem also occurs with other command-line programs,\n>> and indeed it does. For instance, I tried with 'wget' installed via\n>> brew, and it exhibits the same odd behavior. Ævar suggested that there\n>> might be some magic special-casing English, which makes me wonder if\n>> brew builds such magic into gettext(?) or if the magic is part of\n>> MacOS itself.\n>> \n>> [1]: https://public-inbox.org/git/87a7ojlp31.fsf@evledraar.gmail.com/\n> \n> I discovered that moving/renaming /usr/local/share/locale made this\n> issue go away for me. While 'de' and 'fr' have a git.mo file in their\n> LC_MESSAGES subdirectory, there is no 'en' directory.\n> \n> If I copy the 'fr' version to a newly-created 'en' directory, then all my\n> git output is in French; my language order in System Preferences is\n> English (US) -> German -> Japanese.\n> \n> Not sure if this is gettext's or macOS's issue.\n> \n> --Nate Weaver (Wevah)\n\nUpon further digging, this is an issue in gettext's code on macOS:\nThe function _nl_language_preferences_default (in langprefs.c) specifically\nbreaks early when it sees the literal string \"en\" in the list (from the\n\"AppleLanguages\" defaults key), but not when it gets \"en-US\", etc.\n\nI.e., it doesn't check for a prefix.\n\nThis can be fixed (though there might be a better way) simply by replacing\nboth instances of\n\nif (strcmp (buf, \"en\") == 0)\n\nwith\n\nif (strncmp (buf, \"en\", 2) == 0)\n\nin gettext's langprefs.c.\n\n"},{"id":"366735","messageId":"355CD611-C58E-43E1-838C-017CAEF5AD38@derailer.org","threadId":"49348","inReplyTo":"89DD4C7B-7F8B-42C5-81F2-F14D5B2D4CFD@derailer.org","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Nate Weaver","fromEmail":"wevah@derailer.org","sentAt":"2019-01-15T19:06:17Z","receivedAt":"2019-01-15T19:06:21Z","isPatch":false,"sender":{"key":"wevah@derailer.org","avatar":"https://gravatar.com/avatar/46b0edf1785181a23e8b6ff26b92d719ebda2e5445bb6c492fac8e65a3751560?d=mp&s=160"},"body":"\n--Nate Weaver (Wevah)\n\n> On Jan 15, 2019, at 10:43:48, Nate Weaver <wevah@derailer.org> wrote:\n> \n>> On Jan 15, 2019, at 09:35:52, Nate Weaver <wevah@derailer.org> wrote:\n>> \n>>> On Sep 16, 2018, at 02:15:33, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>> \n>>> On Fri, Sep 14, 2018 at 10:20 PM Niko Dzhus <primenico@gmail.com> wrote:\n>>>> Looks like the issue appeared after updating git from brew.\n>>>> \n>>>> A quick search revealed that brew changed how it builds git recently.\n>>>> I think, it just didn't include i18n by default before, so I never\n>>>> noticed this.\n>>>> \n>>>> Anybody here familiar enough with the build process and dependencies\n>>>> of git to pinpoint what exactly is causing this and how to fix it?...\n>>> \n>>> This problem is not specific to Git. Earlier in the thread, Ævar\n>>> asked[1] if the problem also occurs with other command-line programs,\n>>> and indeed it does. For instance, I tried with 'wget' installed via\n>>> brew, and it exhibits the same odd behavior. Ævar suggested that there\n>>> might be some magic special-casing English, which makes me wonder if\n>>> brew builds such magic into gettext(?) or if the magic is part of\n>>> MacOS itself.\n>>> \n>>> [1]: https://public-inbox.org/git/87a7ojlp31.fsf@evledraar.gmail.com/\n>> \n>> I discovered that moving/renaming /usr/local/share/locale made this\n>> issue go away for me. While 'de' and 'fr' have a git.mo file in their\n>> LC_MESSAGES subdirectory, there is no 'en' directory.\n>> \n>> If I copy the 'fr' version to a newly-created 'en' directory, then all my\n>> git output is in French; my language order in System Preferences is\n>> English (US) -> German -> Japanese.\n>> \n>> Not sure if this is gettext's or macOS's issue.\n>> \n>> --Nate Weaver (Wevah)\n> \n> Upon further digging, this is an issue in gettext's code on macOS:\n> The function _nl_language_preferences_default (in langprefs.c) specifically\n> breaks early when it sees the literal string \"en\" in the list (from the\n> \"AppleLanguages\" defaults key), but not when it gets \"en-US\", etc.\n> \n> I.e., it doesn't check for a prefix.\n> \n> This can be fixed (though there might be a better way) simply by replacing\n> both instances of\n> \n> if (strcmp (buf, \"en\") == 0)\n> \n> with\n> \n> if (strncmp (buf, \"en\", 2) == 0)\n> \n> in gettext's langprefs.c.\n\nNevermind: I've been informed that this has already been fixed on the git trunk\nfor gettext, and will be in the next release.\n\n(See: https://savannah.gnu.org/bugs/?49560)\n\n"},{"id":"366763","messageId":"CAPig+cTdP631KLQNM8XfFzcZbMTfMRcvm7wJ67BUUUeGSmoMDw@mail.gmail.com","threadId":"49348","inReplyTo":"355CD611-C58E-43E1-838C-017CAEF5AD38@derailer.org","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-01-15T20:36:50Z","receivedAt":"2019-01-15T20:37:03Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jan 15, 2019 at 2:06 PM Nate Weaver <wevah@derailer.org> wrote:\n> Nevermind: I've been informed that this has already been fixed on the git trunk\n> for gettext, and will be in the next release.\n>\n> (See: https://savannah.gnu.org/bugs/?49560)\n\nThanks for the follow-up report. It's good to know that this is fixed\nat the correct location upstream.\n\nI tried updating the Homebrew bug report[1] regarding this problem\nwith respect to Git in order to add the new information you provided,\nbut the ticket has been \"locked\" so no additional comments can be made\nthere, which is unfortunate.\n\n[1]: https://github.com/Homebrew/homebrew-core/issues/31980\n"},{"id":"366789","messageId":"20190116021658.GB8864@google.com","threadId":"49348","inReplyTo":"89DD4C7B-7F8B-42C5-81F2-F14D5B2D4CFD@derailer.org","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-01-16T02:16:58Z","receivedAt":"2019-01-16T02:17:04Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nate Weaver wrote:\n>>> On Fri, Sep 14, 2018 at 10:20 PM Niko Dzhus <primenico@gmail.com> wrote:\n\n>>>> Looks like the issue appeared after updating git from brew.\n[...]\n>>>> A quick search revealed that brew changed how it builds git recently.\n>>>> I think, it just didn't include i18n by default before, so I never\n>>>> noticed this.\n[...]\n> Upon further digging, this is an issue in gettext's code on macOS:\n> The function _nl_language_preferences_default (in langprefs.c) specifically\n> breaks early when it sees the literal string \"en\" in the list (from the\n> \"AppleLanguages\" defaults key), but not when it gets \"en-US\", etc.\n>\n> I.e., it doesn't check for a prefix.\n>\n> This can be fixed (though there might be a better way) simply by replacing\n> both instances of\n>\n> if (strcmp (buf, \"en\") == 0)\n>\n> with\n>\n> if (strncmp (buf, \"en\", 2) == 0)\n>\n> in gettext's langprefs.c.\n\nNice sleuthing.  Do you have a bug tracking this in homebrew's issue\ntracker, either for the git formula or the gettext formula?\n\nThanks,\nJonathan\n"},{"id":"366790","messageId":"20190116022808.GC8864@google.com","threadId":"49348","inReplyTo":"89DD4C7B-7F8B-42C5-81F2-F14D5B2D4CFD@derailer.org","subject":"Re: [Bug report] Git incorrectly selects language in macos","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-01-16T02:28:08Z","receivedAt":"2019-01-16T02:28:14Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nate Weaver wrote:\n\n> Upon further digging, this is an issue in gettext's code on macOS:\n> The function _nl_language_preferences_default (in langprefs.c) specifically\n> breaks early when it sees the literal string \"en\" in the list (from the\n> \"AppleLanguages\" defaults key), but not when it gets \"en-US\", etc.\n\nSorry I missed your other followup.\n\nAs you mentioned, the fix is at https://savannah.gnu.org/bugs/?49560.\nThere isn't a gettext release yet with that fix, so perhaps\nhttps://github.com/Homebrew/homebrew-core/blob/master/Formula/gettext.rb\ncould be updated to apply that fix as a patch\n(https://docs.brew.sh/Formula-Cookbook#patches).\n\nThanks again and sorry for the noise,\nJonathan\n"}]}