After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770708 - First language preference is ignored when multiple languages are set under Location and Region
First language preference is ignored when multiple languages are set under Lo...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: macOS DMG package
2.8.18
Other Mac OS
: Normal minor
: 2.8
Assigned To: GIMP Bugs
Kristian Rietveld
: 771196 771807 771951 772392 772393 773158 773559 774559 775289 787967 791886 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-09-01 13:43 UTC by Van Fruniken
Modified: 2017-12-23 08:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test script written in Python that prints OS X locale settings to the terminal (478 bytes, text/plain)
2016-10-20 08:28 UTC, Kristian Rietveld
  Details
gettext: fix English fallback for macOS Sierra (1.22 KB, patch)
2016-11-06 12:17 UTC, Kristian Rietveld
none Details | Review

Description Van Fruniken 2016-09-01 13:43:44 UTC
System Language (for me English (US)) is not used (I get the language of my locale which I never selected -- the drop down menu in preferences shows the default "System Language").
Choosing explicitly for EN-US works fine, though (after relaunch).

MacOS 10.11.6 on a late 2012 iMac.
Hint: my language of second choice in the system prefs is Dutch, and maybe the fetch of the "system language" id fails, so it reverts to Dutch.
Comment 1 Jehan 2016-09-03 16:35:34 UTC
Why do you have a locale different than your system language? I guess this is the question whose answer is needed.

Normally Unix systems heavily rely on the locale mechanism, and setting a system language should be equivalent to set a new locale. Does OSX use a different localization mechanism?
Comment 2 Van Fruniken 2016-09-04 08:23:11 UTC
There are many reasons in non-English speaking reasons to have an English UI rather than the local language: expats, international organisations in Europe with its small and multilingual regions; English is the Lingua Franca, and in technical settings, its wordings, documentation, menus and keywords are much more precise than often inaccurate translations in the local language; I have been teaching in English all my life and need(ed) to communicate with my students in the proper jargon; ...
Another rationale for choosing a language different from the system language is that it may be necessary to use an app like GIMP to do demonstrations to a public different form the working environment (especially in this age of laptops and international travel).
  Moreover on the Mac, the preferences contain a priority list of languages to be used by each application. The application itself automatically picks from its resources  the first language in that list for which it has a string dictionary for text items in that language. In other words, for the macOS platform specific expected behavior that the fo
  However, it is OK for individual apps to choose their own language prefs, which can override the system ones, so the GIMP approach is fine (with language names in their own language: Deutsch, Nederlands, Français,...), except that when it states "System language", it should use the above mentioned mechanism, provided by the system.
  It should be said that GIMP.app for macOS already has all these resources in the proper format and location (<app bundle="/Applications/GIMP.app">/Contents/Resources/<2LetterLanguageCode>.lproj/<someAppName="GtkOSXApplication">.string) for the system language selection to work.
All that needs to be done for the default (menu item="System Language") is ask the system to provide the proper language code.
  My point is just that GIMP on macOS doesn't operate as advertised in the wording of its own language prefs menu for the default "System Language" case.
  Almost perfect, but not platform expected behavior for the default case.
Comment 3 Van Fruniken 2016-09-04 08:25:55 UTC
There are many reasons in non-English speaking regions to have an English UI rather than the local language: expats, international organisations in Europe with its small and multilingual regions; English is the Lingua Franca, and in technical settings, its wordings, documentation, menus and keywords are much more precise than often inaccurate translations in the local language; I have been teaching in English all my life and need(ed) to communicate with my students in the proper jargon; ...
Another rationale for choosing a language different from the system language is that it may be necessary to use an app like GIMP to do demonstrations to a public different form the working environment (especially in this age of laptops and international travel).
  Moreover on the Mac, the preferences contain a priority list of languages to be used by each application. The application itself automatically picks from its resources  the first language in that list for which it has a string dictionary for text items in that language. In other words, for the macOS platform specific expected behavior that the fo
  However, it is OK for individual apps to choose their own language prefs, which can override the system ones, so the GIMP approach is fine (with language names in their own language: Deutsch, Nederlands, Français,...), except that when it states "System language", it should use the above mentioned mechanism, provided by the system.
  It should be said that GIMP.app for macOS already has all these resources in the proper format and location (<app bundle="/Applications/GIMP.app">/Contents/Resources/<2LetterLanguageCode>.lproj/<someAppName="GtkOSXApplication">.string) for the system language selection to work.
All that needs to be done for the default (menu item="System Language") is ask the system to provide the proper language code.
  My point is just that GIMP on macOS doesn't operate as advertised in the wording of its own language prefs menu for the default "System Language" case.
  Almost perfect, but not platform expected behavior for the default case.
Comment 4 Van Fruniken 2016-09-04 08:31:20 UTC
Sorry for the duplicate post just to edit one misspelled word. -- couldn't find how to delete the superfluous comment.
Comment 5 Van Fruniken 2016-09-04 08:32:02 UTC
Sorry for the duplicate post just to edit one misspelled word. -- couldn't find how to delete the superfluous comment.
Comment 6 Jehan 2016-09-04 22:13:26 UTC
> There are many reasons in non-English speaking reasons to have an English UI rather than the local language <snip>

Not sure if there is misunderstanding since there was no problem on this topic. Of course there are good reasons to have your UI in whatever language you want, which is why GIMP provides the possibility.

I was noting though that you were saying that you had a system locale different from your system language, even though you said you did nothing to set a different locale. So I just wonder how this could happen. GIMP indeed uses the locale to find the default language.

So just to make sure I understand: your OSX system preferences have US English as top language (and Dutch as second), all other applications in OSX are in English, but GIMP which shows up in Dutch by default (when set as "System Language" in GIMP preferences). And when you type the command `locale` in a terminal, it shows a list of "nl" locales (especially in LANG or LANGUAGE or LC_ALL). Is that a good summary?
Comment 7 Michael Natterer 2016-09-04 23:15:39 UTC
Your 2.8.14 is outdated. Please try the latest 2.8.18 DMG and report back.
Comment 8 Van Fruniken 2016-09-05 08:54:13 UTC
To be sure, I updated GIMP to 2.8.18 in which the UI pref still remembered forcing US English, then reset the language pref to 'System Language', restarted GIMP and got again menus, splash screen, etc., in Dutch. FYI, my System language preferences are US English (US), Nederlands, Español, Français, Deutsch, in that order. Terminal>locale yields 'LANG=0', 'LC_ALL='. Apart from that your last paragraph "So... correctly summarizes the situation.
Please note that I was not aware of the Unix mechanisms behind this (and the 'locale' command, which appeared in Darwin 10.4), therefore I have been using the term 'locale' rather loosely, as the UI language preferred by the user.
Comment 9 Michael Natterer 2016-09-05 09:16:16 UTC
Thanks for checking.

Kris, could you have a look at this?
Comment 10 Van Fruniken 2016-09-05 09:17:12 UTC
FYI: Terminal>locale yields: LANG=; LC_COLLATE="C"; LC_CTYPE="UTF-8"; LC_MESSAGES="C"; LC_MONETARY="C"; LC_NUMERIC="C"; LC_TIME="C"; LC_ALL=
I read somewhere that only BSD style Unixen know about the string UTF-8.
I also read that macOS has a richer, native API than getdefaultlocale, namely: (and its Cocoa equivalent, NSLocale; watch Swift API conventions for yet another name).
Comment 11 Michael Schumacher 2016-09-06 11:26:20 UTC
BTW, do we know why this seems to have worked for people in the past?
Comment 12 Michael Schumacher 2016-09-10 17:17:56 UTC
Bug 771196 has additional information - seems like we skip the first language in the list, specifically. Do we have an off-by-one error somewhere?
Comment 13 Michael Natterer 2016-09-11 18:45:20 UTC
I guess we need to add some OS X specific code to app/language.c, we only
special case windows there, and the UNIX-style default impl is obviously
not good enough on OS X.
Comment 14 Michael Schumacher 2016-09-12 08:08:12 UTC
*** Bug 771196 has been marked as a duplicate of this bug. ***
Comment 15 Michael Schumacher 2016-09-12 08:08:49 UTC
Let's use the summary of the duplicate.
Comment 16 Ralf G. R. Bergs 2016-09-18 20:23:08 UTC
I have the same issue, running GIMP 2.8.18 under macOS 10.12 (16A323).

I'm using GIMP since ages, but it was never a problem for me so far as I never had multiple languages set (I always set my OS language to EN-US).

Now that there is Siri in macOS I wanted to play with it, so I added my native language "German." But it is NOT the primary language, and when I display my environment, I see the following related to locale:

LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8

Still GIMP suddenly came up in German. I was using a somewhat older version (2.8.8?), and after I upgraded to 2.8.18 I could finally force the language to English. Using "System setting" made GIMP come up in German.
Comment 17 Daniel Bair 2016-09-22 07:34:49 UTC
I have the same problem, so my bug report https://bugzilla.gnome.org/show_bug.cgi?id=771807 should be marked as a duplicate of this.

I see a language chooser on Gimp 2.8.18 running on OSX 10.11 but the language chooser is missing when running on macOS 10.12 with the same Gimp version.

Is there a command line switch that can force the language? Or can I copy over a preference file from a machine running OSX 10.11 and Gimp 2.8.18 to my macOS 10.12 machine?
Comment 18 Daniel Bair 2016-09-22 07:40:09 UTC
Actually that was Gimp 2.8.14 that didn't have a language chooser. It is there in Gimp 2.8.18 on macOS Sierra. Sorry for that.
Comment 19 Daniel Bair 2016-09-22 07:47:42 UTC
*** Bug 771807 has been marked as a duplicate of this bug. ***
Comment 20 Jehan 2016-09-26 11:59:42 UTC
Setting the "newcomers" tag. That should not be too hard to debug and get a proper OSX implementation for a OSX dev.
Comment 21 Michael Schumacher 2016-09-26 12:40:52 UTC
BTW, we should check what gettext does - the command line utility, in this case: http://linuxcommand.org/man_pages/gettext1.html
Comment 22 Kristian Rietveld 2016-10-20 08:27:24 UTC
Please allow me to summarize to determine whether I have understood the bug report correctly:

 - In OS X it is possible to give multiple language preferences, one language is selected as "primary".

 - In GIMP you can select a language preference. When set to a specific language, this works fine.

 - In GIMP you can select "System Language" as language preference. This should choose the language selected in OS X preferences as "Primary". But this is no longer happening.

So the problem is that when "System Language" is chosen, not the OS X "Primary" language is selected but another.


I cannot immediately reproduce this myself and unfortunately I cannot upgrade to Sierra at this moment. However, I have an idea what might be going wrong.


When "System Language" is selected in GIMP, then setlocale() is initialized with the empty string. This would indicate to initialize using the native environment.

For OS X, gettext appears to determine the default language using CFLocaleCopyCurrent(). However, the Apple documentation notes:

"Note that locale settings are independent of the user’s language setting. The language of the current locale may not correspond to the language at the first index in the AppleLanguages array from user defaults. For more details, see Locale Concepts in Locales Programming Guide; see also CFLocaleCopyPreferredLanguages."

So it could be well possible that CFLocaleCopyCurrent() gives a locale that is different from the primary language on Sierra.

To test this hypothesis I have written a simple Python script (see attachment) that prints the result of both CFLocaleCopyCurrent() and CFLocaleCopyPreferredLanguages() to the terminal. Could some users that experience this problem on Mac OS Sierra please inspect the source code of the Python script and if confident run the script within the Terminal? And please post the output in this bug report. The script only performs two CoreFoundation calls.

The output for my system (10.11.5) is as follows, the latter two languages were added for testing:

"
The default locale used by GIMP is:  en_NL

The preferred languages configured for this system are:
   en
   nl
   de
   es
"

So, we would be interested to know whether the default locale *differs* from the first preferred language.
Comment 23 Kristian Rietveld 2016-10-20 08:28:12 UTC
Created attachment 338077 [details]
Test script written in Python that prints OS X locale settings to the terminal
Comment 24 Ralf G. R. Bergs 2016-10-20 10:00:19 UTC
$ /usr/bin/python showlang.py
The default locale used by GIMP is:  en_US_POSIX@currency=EUR

The preferred languages configured for this system are:
   en-US
   de-US

This is on macOS 10.12.1 Beta (16B2548a).
Comment 25 Daniel Bair 2016-10-20 12:11:35 UTC
The default locale used by GIMP is:  en_US

The preferred languages configured for this system are:
   en-US
   th-US
   my-US
   ksw-Mymr-US

I had already set the language in GIMP to English earlier.

The way GIMP was displaying before on Sierra was first showing the last language in the list (Sgaw-Karen/Myanmar) and then substituting the earlier languages where strings were missing.
Comment 26 qpoint 2016-10-20 12:39:21 UTC
The default locale used by GIMP is:  en_CA

The preferred languages configured for this system are: 
      en-CA
      en-GB
      gd-CA
      hi-CA
      ja-CA
      ru-CA
      el-CA

I had set the second language to English - Great Britain just so it would stop defaulting to any of the foreign languages within my list.
Comment 27 Kristian Rietveld 2016-10-29 09:32:38 UTC
Thanks for the responses. Based on these we can say that

"So it could be well possible that CFLocaleCopyCurrent() gives a locale that is different from the primary language on Sierra."

does not hold, at least when run stand-alone.

We do note that the preferred languages are now suffixed with the region, which was not the case before Sierra. This appears to be explained in:

https://developer.apple.com/library/content/technotes/tn2418/_index.html


GIMP configures gettext with the empty string for the system language, causing gettext to use the "default locale".

The OS X menus for GIMP use the usual Cocoa translation system and therefore take another path. According to the text linked above, Sierra attempts to perform "smart language fallbacks" for missing translations. This may explain a difference between language selected for the menus and the other interface text. But this does not explain why the main interface text would use a locale different from the default locale. (Unless the default locale is changed somehow after the menus started displaying).

So I will have to dig a bit deeper in how localizations are set ...
Comment 28 Michael Schumacher 2016-10-29 11:08:10 UTC
*** Bug 773559 has been marked as a duplicate of this bug. ***
Comment 29 Michael Schumacher 2016-10-29 11:08:55 UTC
*** Bug 773158 has been marked as a duplicate of this bug. ***
Comment 30 Michael Schumacher 2016-10-29 11:09:09 UTC
*** Bug 772393 has been marked as a duplicate of this bug. ***
Comment 31 Michael Schumacher 2016-10-29 11:10:14 UTC
*** Bug 772392 has been marked as a duplicate of this bug. ***
Comment 32 Michael Schumacher 2016-10-29 11:11:27 UTC
*** Bug 771951 has been marked as a duplicate of this bug. ***
Comment 33 Kristian Rietveld 2016-11-06 07:01:20 UTC
I am happy to announce that I seem to have managed to reproduce the problem, by immediately inserting the preferred language output from Sierra into gettext. As already noted Sierra now includes region suffixes and I suspect this is causing the problem. And as noted by others, it indeed looks like the first language is ignored.

My plan is to work out a fix and roll a DMG for you all to test (and then use if it fixes the problem ;).
Comment 34 Kristian Rietveld 2016-11-06 07:02:36 UTC
Suspecting a gettext bug, I am moving this to the DMG package component.
Comment 35 Kristian Rietveld 2016-11-06 12:16:43 UTC
The problem here is that the English language as fallback is handled in a special way by gettext. This is caused by the fact that English is the default language for many programs and a translation file does not exist for the default language.

If you try a language setting such as:

   LANG="en_FR:de_CA:nl"


then most of the interface will show in German, if en_FR does not exist. "en" is tried as fallback, but the translation file does not exist.

Therefore, in the Mac OS X support for gettext, iteration of the preferred languages is stopped as soon as English is detected.  This ensures English functions as primary fallback (if no translation is shown, the untranslated string (typically English) is show).

The identification only checked for "en", but in Sierra the region is always suffixed, so English was left undetected. The attached patch fixes this.

I will also submit the patch to the gettext developers. I hope to have an updated DMG image later today for testing.
Comment 36 Kristian Rietveld 2016-11-06 12:17:23 UTC
Created attachment 339188 [details] [review]
gettext: fix English fallback for macOS Sierra
Comment 37 Kristian Rietveld 2016-11-06 13:28:14 UTC
Test building available here:

https://download.gimp.org/pub/gimp/v2.8/osx/testing/gimp-2.8.18-x86_64.6nov2016.dmg


SHA1 checksum: 99e80cecbdcd779ab3b586683856f9ee23e8e98c

Please report back whether it works and fixes the problem; thanks!
Comment 38 Michael Schumacher 2016-11-06 13:36:26 UTC
... and for users of BitTorrent clients:

https://download.gimp.org/pub/gimp/v2.8/osx/testing/gimp-2.8.18-x86_64.6nov2016.dmg.torrent
Comment 39 yogaman101 2016-11-07 01:02:47 UTC
The Test building in Comment 37 solved this bug for me. 

Thank you Kristian Rietveld for your quick dispatch of this bug. 

Fwiw, I have:

sh> /usr/bin/python ~/Downloads/showlang.py
The default locale used by GIMP is:  en_US

The preferred languages configured for this system are:
   en-US
   hi-US
sh>

Sadly, I do not read Hindi, so the broken version of GIMP was very broken for me. But now all is peaceful in GIMP menu-land again.
Comment 40 yogaman101 2016-11-07 02:36:10 UTC
Additional info: 
Bug appears in GIMP 2.8.16 and 2.8.18 on MacOS Sierra 10.12.1

Thanks again.
Comment 41 Ralf G. R. Bergs 2016-11-07 08:42:52 UTC
Now works for me as well. I'm on macOS Sierra 10.12.2 Beta (16C32f).

For reference:

$ /usr/bin/python showlang.py
The default locale used by GIMP is:  en_US_POSIX@currency=EUR

The preferred languages configured for this system are:
   en-US
   de-US

To test your fix I set GIMP back to use "System Settings", and GIMP's UI language is still English.

Thank you!
Comment 42 Kristian Rietveld 2016-11-08 20:03:42 UTC
Thanks for testing.

We have submitted the patch to the gettext developers: https://savannah.gnu.org/bugs/index.php?49560

We'll patch gettext in our DMG image for the upcoming releases.
Comment 43 Michael Natterer 2016-11-15 12:39:57 UTC
Can we just move this updated DMG out of the testing area, rename it
and close this bug?
Comment 44 Michael Schumacher 2016-11-17 08:49:10 UTC
*** Bug 774559 has been marked as a duplicate of this bug. ***
Comment 45 Kristian Rietveld 2016-11-17 20:57:42 UTC
(In reply to Michael Natterer from comment #43)
> Can we just move this updated DMG out of the testing area, rename it
> and close this bug?

schumaml has just done so.

I will commit the gettext patch & build file changes to GIMP git once I get around to it (probably this weekend) and then close this bug.
Comment 46 Kristian Rietveld 2016-11-19 20:29:47 UTC
Fixed in gimp-2-8.

commit f2e483df028ca05bcfbf3dcdd92e89ed1d67dd7a
Author: Kristian Rietveld <kris@loopnest.org>
Date:   Sat Nov 19 21:25:54 2016 +0100

    Bug 770708 - First language preference is ignored when multiple ...

    ... languages are set under Location and Region

    We tracked this down to be a gettext bug, so include the gettext patch into
    our DMG build. The gettext patch has also been submitted upstream.
Comment 47 Michael Schumacher 2016-11-29 17:11:22 UTC
*** Bug 775289 has been marked as a duplicate of this bug. ***
Comment 48 Jehan 2017-09-26 22:06:01 UTC
*** Bug 787967 has been marked as a duplicate of this bug. ***
Comment 49 Michael Schumacher 2017-12-23 08:51:00 UTC
*** Bug 791886 has been marked as a duplicate of this bug. ***