10

Is there a way to download MinGW/MSYS2 with gcc, that is not localized? Localized gcc causes all warnings to become errors in CodeBlocks, if the system language is not English.
This bug is also reported here:

http://forums.codeblocks.org/index.php/topic,9489.msg67120.html

The thread also contains a working solution to the problem, but if one could download a non-localized version in the first place, this would be much more convenient.

Henke
  • 4,445
  • 3
  • 31
  • 44
x squared
  • 3,173
  • 1
  • 26
  • 41

5 Answers5

11

I'm pretty sure the following is not the "recommended solution", but I personally gave up on trying to find one. So: My locale is da (Danish) which causes exactly the kind of problem you describe.

My solution? Simply erase the locale used, causing the system to default to english: i.e. in my case erase the folder:

C:\MinGW\share\locale\da

(In more recent versions the location might be for example msys64\usr\share\locale\sv where in this case sv represents Swedish.)

Why on earth anyone coding in C/C++ would want their tools to output localized error-messages is beyond me...

Henke
  • 4,445
  • 3
  • 31
  • 44
S.C. Madsen
  • 5,100
  • 5
  • 32
  • 50
  • 3
    Well, i guess it's the easiest solution to this problem. Thank you :) – x squared Jul 18 '12 at 11:17
  • Although this is (currently) my preferred solution, I just discovered that whenever I install a new package, the language (in my case `sv`) is installed back again. So I might have to delete that folder every time I install a new package ... (SIGH!) – Henke Feb 06 '22 at 13:38
9

Gcc & G++ in mingw use the environment variable LC_ALL to define the language at top level (if this variable is set), defaulting with the system locale if available, and then english if the locale does not exist.

If you want to force those tools to output their messages in english, just add/edit the environment variable LC_ALL with the value en_US.UTF-8

Alex Garcia
  • 773
  • 7
  • 21
3

Use the commmand

locale -a

to see a list of enabled locales. To use USA English, I set below environment variables in my bash's source file

export LANG=en_US.UTF-8
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
Yorkwar
  • 1,204
  • 1
  • 11
  • 27
1

The following worked for me.

After installing MSYS2, I tried :

$ drivel
-bash: drivel: kommandot finns inte

As you can see, kommandot finns inte is not English. So I ran : 1

$ echo "export LANG=en_US.UTF-8" > /etc/profile.d/english.sh

Then I closed and restarted MSYS2, and tried running drivel again :

$ drivel
-bash: drivel: command not found

Yay! – It's now in English: command not found.


1 My solution is inspired by this answer.

Henke
  • 4,445
  • 3
  • 31
  • 44
-1

The solution I posted yesterday does its job.
But it restores English for MSYS2 only, and not for other applications that may suffer from the same problem. In the next section, I provide a system-wide solution.

System-wide solution 1

Press WinKey and type envi.
Then click Edit the system environment variables > Environment Variables....

The Environment Variables window opens.
The upper frame is titled User variables for <username>,
and the lower frame is titled System variables.

Under System variables, look for variables LANG and/or LC_ALL.
In my case, the variable LANG was set to my local language, and not to en_US.UTF-8.
I just deleted the LANG variable. Then I restarted MSYS2, and English was restored.

Note

The variables LANG and LC_ALL do the same thing.
The only difference is that LC_ALL overrides LANG.
I experimented with this myself, and can confirm that – yes indeed :
LC_ALL takes precedence over LANG.


1 Inspired by this answer.

Henke
  • 4,445
  • 3
  • 31
  • 44