[GRASS-dev] more on locale problem

So I am now completely baffled as to why GRASS is not working on my colleague’s computer. it is a pretty new MacBook (last 6 months) and he has not installed much on it–Office, Mendeley. It is running the most current version of Lion (10.7.4).

There are repeated problems with locale on it. Here is an example that works fine on my computer also running Lion.

import locale

locale.getdefaultlocale()

Traceback (most recent call last):
File “”, line 1, in
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py”, line 496, in getdefaultlocale
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py”, line 428, in _parse_localename
ValueError: unknown locale: UTF-8

I don’t know where it is getting UTF-8. The GUI code in GRASS calls the language en_ES.UTF-8, but this is running Python outside of GRASS. I’ve tried setting locale to es_EN, and to C. But we still get this error when locale.getdefaultlocale() is run in wx GUI.

Any ideas???

Michael


C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

2012/7/26 Michael Barton <Michael.Barton@asu.edu>:

So I am now completely baffled as to why GRASS is not working on my
colleague's computer. it is a pretty new MacBook (last 6 months) and he has
not installed much on it--Office, Mendeley. It is running the most current
version of Lion (10.7.4).

There are repeated problems with locale on it. Here is an example that works
fine on my computer also running Lion.

Hi Micheal,
the problems I think it's related to the improvement in preferences.py
to give the capabilities to people to switch the language. It was
added by me in grass7, later martin did some changes and during code
sprint MarkusN backported it.
Is Mac using grass.sh to start GRASS or something different?

could your colleague set the language in ~/.grassrc6 adding LANG:
your_languages?

Michael

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

Michael and others,
Michael's 6.4.3 menus aren't working here, I did try adding
en_US.UTF-8
to .grassrc6 but the complaints are the same
############################
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
2012-07-26 11:56:43.011 Python[1916:e0f] CFURLCreateWithString was passed this invalid URL string: '/System/Library/CoreServices/CommonCocoaPanels.bundle' (a file system path instead of an URL string). The URL created will not work with most file URL functions. CFURLCreateWithFileSystemPath or CFURLCreateWithFileSystemPathRelativeToBase should be used instead.
############################
by the way my system preferences are set to english but the region is set to Spain.
cli is working
As you know in R the language is forced with
defaults write org.R-project.R force.LANG en_US.UTF-8
Is there something similar in GRASS?
A
On Thursday, July 26, 2012 08:16 CEST, Michael Barton <Michael.Barton@asu.edu> wrote:

So I am now completely baffled as to why GRASS is not working on my colleague's computer. it is a pretty new MacBook (last 6 months) and he has not installed much on it--Office, Mendeley. It is running the most current version of Lion (10.7.4).

There are repeated problems with locale on it. Here is an example that works fine on my computer also running Lion.

import locale
locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
ValueError: unknown locale: UTF-8

I don't know where it is getting UTF-8. The GUI code in GRASS calls the language en_ES.UTF-8, but this is running Python outside of GRASS. I've tried setting locale to es_EN, and to C. But we still get this error when locale.getdefaultlocale() is run in wx GUI.

Any ideas???

Michael
_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu/&gt;

As you mentioned Michael, there was discussion of this problem a few times in the past.

The problem setting is not LANG, though, it's LC_CTYPE. The system is somehow setting that to "UTF-8", and Python checks LC_CTYPE (and LC_ALL next) before it checks LANG, so setting LANG in GRASS won't help, as Agustin found.

On Jul 26, 2012, at 5:03 AM, Agustin Angel Diez Castillo wrote:

Michael and others,
Michael's 6.4.3 menus aren't working here, I did try adding
en_US.UTF-8
to .grassrc6 but the complaints are the same
############################
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
2012-07-26 11:56:43.011 Python[1916:e0f] CFURLCreateWithString was passed this invalid URL string: '/System/Library/CoreServices/CommonCocoaPanels.bundle' (a file system path instead of an URL string). The URL created will not work with most file URL functions. CFURLCreateWithFileSystemPath or CFURLCreateWithFileSystemPathRelativeToBase should be used instead.
############################
by the way my system preferences are set to english but the region is set to Spain.
cli is working
As you know in R the language is forced with
defaults write org.R-project.R force.LANG en_US.UTF-8
Is there something similar in GRASS?
A
On Thursday, July 26, 2012 08:16 CEST, Michael Barton <Michael.Barton@asu.edu> wrote:

So I am now completely baffled as to why GRASS is not working on my colleague's computer. it is a pretty new MacBook (last 6 months) and he has not installed much on it--Office, Mendeley. It is running the most current version of Lion (10.7.4).

There are repeated problems with locale on it. Here is an example that works fine on my computer also running Lion.

import locale
locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
ValueError: unknown locale: UTF-8

I don't know where it is getting UTF-8. The GUI code in GRASS calls the language en_ES.UTF-8, but this is running Python outside of GRASS. I've tried setting locale to es_EN, and to C. But we still get this error when locale.getdefaultlocale() is run in wx GUI.

Any ideas???

Michael

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

First Pogril: Why is life like sticking your head in a bucket filled with hyena offal?
Second Pogril: I don't know. Why IS life like sticking your head in a bucket filled with hyena offal?
First Pogril: I don't know either. Wretched, isn't it?

-HitchHiker's Guide to the Galaxy

I was worried that there might be 2 problems compounded here, but no longer think so.

Yesterday, I compiled under Snow Leopard and today was able to test on Lion. It runs fine on my Lion machine AFTER manually editing .grassrc6 and adding

LANG: en_US.UTF-8

The fact that this is needed is a problem in itself, but does provide a workaround but seemingly only to a US English machine. A computer with Spanish (or other?) localization will still bomb. This is ironic, of course, since the changes were designed to improve multi-lingual capabilities of GRASS. But this is what happens with such a complex system (a great, if annoying, example of CAS emergent effects).

William Kyngesburye has a promising diagnosis that the issue lies with LC_CTYPE. Somehow, this is set incorrectly for your and Carlos' machine with a "UTF-8" designation instead of a "UTF8" designation. But I don't know how it got set badly or how to change it to test this hypothesis.

Hopefully others can suggest the beginnings of a solution to test.

Michael

On Jul 26, 2012, at 3:03 AM, Agustin Angel Diez Castillo wrote:

Michael and others,
Michael's 6.4.3 menus aren't working here, I did try adding
en_US.UTF-8
to .grassrc6 but the complaints are the same
############################
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
2012-07-26 11:56:43.011 Python[1916:e0f] CFURLCreateWithString was passed this invalid URL string: '/System/Library/CoreServices/CommonCocoaPanels.bundle' (a file system path instead of an URL string). The URL created will not work with most file URL functions. CFURLCreateWithFileSystemPath or CFURLCreateWithFileSystemPathRelativeToBase should be used instead.
############################
by the way my system preferences are set to english but the region is set to Spain.
cli is working
As you know in R the language is forced with
defaults write org.R-project.R force.LANG en_US.UTF-8
Is there something similar in GRASS?
A
On Thursday, July 26, 2012 08:16 CEST, Michael Barton <Michael.Barton@asu.edu> wrote:

So I am now completely baffled as to why GRASS is not working on my colleague's computer. it is a pretty new MacBook (last 6 months) and he has not installed much on it--Office, Mendeley. It is running the most current version of Lion (10.7.4).

There are repeated problems with locale on it. Here is an example that works fine on my computer also running Lion.

import locale
locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
ValueError: unknown locale: UTF-8

I don't know where it is getting UTF-8. The GUI code in GRASS calls the language en_ES.UTF-8, but this is running Python outside of GRASS. I've tried setting locale to es_EN, and to C. But we still get this error when locale.getdefaultlocale() is run in wx GUI.

Any ideas???

Michael
_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, Center for Social Dynamics and Complexity;

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

For both Snow Leopard and Lion...

anthgradpc7:grass64_rb cmbarton$ $LC_CTYPE

anthgradpc7:grass64_rb cmbarton$ $LC_ALL

anthgradpc7:grass64_rb cmbarton$ $LANG
-bash: en_US.UTF-8: command not found

Maybe this is the wrong way to see what is set for these, but there is nothing for LC_CTYPE or LC_ALL for either of my computers.

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
    http://www.public.asu.edu/~cmbarton

On Jul 26, 2012, at 6:26 AM, William Kyngesburye wrote:

As you mentioned Michael, there was discussion of this problem a few times in the past.

The problem setting is not LANG, though, it's LC_CTYPE. The system is somehow setting that to "UTF-8", and Python checks LC_CTYPE (and LC_ALL next) before it checks LANG, so setting LANG in GRASS won't help, as Agustin found.

On Jul 26, 2012, at 5:03 AM, Agustin Angel Diez Castillo wrote:

Michael and others,
Michael's 6.4.3 menus aren't working here, I did try adding
en_US.UTF-8
to .grassrc6 but the complaints are the same
############################
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
ERROR: unknown locale: UTF-8
2012-07-26 11:56:43.011 Python[1916:e0f] CFURLCreateWithString was passed this invalid URL string: '/System/Library/CoreServices/CommonCocoaPanels.bundle' (a file system path instead of an URL string). The URL created will not work with most file URL functions. CFURLCreateWithFileSystemPath or CFURLCreateWithFileSystemPathRelativeToBase should be used instead.
############################
by the way my system preferences are set to english but the region is set to Spain.
cli is working
As you know in R the language is forced with
defaults write org.R-project.R force.LANG en_US.UTF-8
Is there something similar in GRASS?
A
On Thursday, July 26, 2012 08:16 CEST, Michael Barton <Michael.Barton@asu.edu> wrote:

So I am now completely baffled as to why GRASS is not working on my colleague's computer. it is a pretty new MacBook (last 6 months) and he has not installed much on it--Office, Mendeley. It is running the most current version of Lion (10.7.4).

There are repeated problems with locale on it. Here is an example that works fine on my computer also running Lion.

import locale
locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
ValueError: unknown locale: UTF-8

I don't know where it is getting UTF-8. The GUI code in GRASS calls the language en_ES.UTF-8, but this is running Python outside of GRASS. I've tried setting locale to es_EN, and to C. But we still get this error when locale.getdefaultlocale() is run in wx GUI.

Any ideas???

Michael

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

First Pogril: Why is life like sticking your head in a bucket filled with hyena offal?
Second Pogril: I don't know. Why IS life like sticking your head in a bucket filled with hyena offal?
First Pogril: I don't know either. Wretched, isn't it?

-HitchHiker's Guide to the Galaxy

On Thu, Jul 26, 2012 at 11:40 PM, Michael Barton <Michael.Barton@asu.edu> wrote:

For both Snow Leopard and Lion...

anthgradpc7:grass64_rb cmbarton$ $LC_CTYPE

try:
echo $LC_CTYPE

anthgradpc7:grass64_rb cmbarton$ $LC_ALL

try:
echo $LC_ALL

anthgradpc7:grass64_rb cmbarton$ $LANG
-bash: en_US.UTF-8: command not found

try:
echo $LANG

or try

set | grep UTF

Markus

Can I set LC_CTYPE and LC_ALL with the normal bash export commands?

Michael Barton
School of Human Evolution &Social Change
Center for Social Dynamics & Complexity
Arizona State University

...Sent from my iPad

On Jul 27, 2012, at 2:02 AM, "Markus Neteler" <neteler@osgeo.org> wrote:

On Thu, Jul 26, 2012 at 11:40 PM, Michael Barton <Michael.Barton@asu.edu> wrote:

For both Snow Leopard and Lion...

anthgradpc7:grass64_rb cmbarton$ $LC_CTYPE

try:
echo $LC_CTYPE

anthgradpc7:grass64_rb cmbarton$ $LC_ALL

try:
echo $LC_ALL

anthgradpc7:grass64_rb cmbarton$ $LANG
-bash: en_US.UTF-8: command not found

try:
echo $LANG

or try

set | grep UTF

Markus

On Fri, Jul 27, 2012 at 5:41 PM, Michael Barton <Michael.Barton@asu.edu> wrote:

Can I set LC_CTYPE and LC_ALL with the normal bash export commands?

sure, e.g.

       export LANG=en_US
       export LANGUAGE=en_US
       export LC_MESSAGES=en_US

Markus

Setting LC_CTYPE and LC_ALL to the correct language fixes all problems. This is very good!

Unfortunately, putting this into .grass.bashrc doesn't work, nor does putting this into .profile nor .grassrc6 (a long shot). So you can't fix this so that GRASS works when you open it. At the moment, the only way this works is to start GRASS, quit the GUI, manually export LC_CTYPE and LC_ALL, and restart the GUI.

Somehow this needs to be fixed.

Michael

On Jul 27, 2012, at 2:55 PM, Markus Neteler wrote:

On Fri, Jul 27, 2012 at 11:27 PM, Michael Barton <Michael.Barton@asu.edu> wrote:

Thanks. What is Spanish, es_ES?

yes. or
es_ES.UTF8

On Fri, Jul 27, 2012 at 11:28 PM, Michael Barton <Michael.Barton@asu.edu> wrote:

Also, where would I put these to make sure that they are recognized by GRASS when it starts?

I guess into

$HOME/.grass.bashrc

Markus

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

Michael:

Unfortunately, putting this into .grass.bashrc doesn't work,
nor does putting this into .profile nor .grassrc6 (a long
shot).

how about exporting it in ~/.bashrc?

If put in .grass.bashrc it might only be found if you start the gui
from the GRASS> terminal prompt with g.gui, since it gets sourced late
in the game.

Hamish

Tried it. Didn't work. Any other ideas? I'm completely out of thoughts on this beyond roll back to before the change.

Michael

On Jul 27, 2012, at 7:02 PM, Hamish wrote:

Michael:

Unfortunately, putting this into .grass.bashrc doesn't work,
nor does putting this into .profile nor .grassrc6 (a long
shot).

how about exporting it in ~/.bashrc?

If put in .grass.bashrc it might only be found if you start the gui
from the GRASS> terminal prompt with g.gui, since it gets sourced late
in the game.

Hamish

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

Set it in ~/.bash_profile, I don't think Terminal on OS X reads ~/.bashrc.

On Jul 27, 2012, at 10:45 PM, Michael Barton wrote:

Tried it. Didn't work. Any other ideas? I'm completely out of thoughts on this beyond roll back to before the change.

Michael

On Jul 27, 2012, at 7:02 PM, Hamish wrote:

Michael:

Unfortunately, putting this into .grass.bashrc doesn't work,
nor does putting this into .profile nor .grassrc6 (a long
shot).

how about exporting it in ~/.bashrc?

If put in .grass.bashrc it might only be found if you start the gui
from the GRASS> terminal prompt with g.gui, since it gets sourced late
in the game.

Hamish

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"We are at war with them. Neither in hatred nor revenge and with no particular pleasure I shall kill every ___ I can until the war is over. That is my duty."

"Don't you even hate 'em?"

"What good would it do if I did? If all the many millions of people of the allied nations devoted an entire year exclusively to hating the ____ it wouldn't kill one ___ nor shorten the war one day."

<Ha, ha> "And it might give 'em all stomach ulcers."

- Tarzan, on war

Watching the Olympics opening and trying every possible start up file. Thanks for the suggestions. But...

Just tried it in .bash_profile and it didn't work either.

So far...

.bashrc
.profile
.bash_profile
.grass.bash
.grassrc6

The only thing that has helped so far is setting this from the terminal once GRASS is started.

Just to ask, there is no chance that LC_CTYPE and LC_ALL are getting reset in a GRASS start up file is there?

Michael

On Jul 27, 2012, at 9:08 PM, William Kyngesburye wrote:

Set it in ~/.bash_profile, I don't think Terminal on OS X reads ~/.bashrc.

On Jul 27, 2012, at 10:45 PM, Michael Barton wrote:

Tried it. Didn't work. Any other ideas? I'm completely out of thoughts on this beyond roll back to before the change.

Michael

On Jul 27, 2012, at 7:02 PM, Hamish wrote:

Michael:

Unfortunately, putting this into .grass.bashrc doesn't work,
nor does putting this into .profile nor .grassrc6 (a long
shot).

how about exporting it in ~/.bashrc?

If put in .grass.bashrc it might only be found if you start the gui
from the GRASS> terminal prompt with g.gui, since it gets sourced late
in the game.

Hamish

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"We are at war with them. Neither in hatred nor revenge and with no particular pleasure I shall kill every ___ I can until the war is over. That is my duty."

"Don't you even hate 'em?"

"What good would it do if I did? If all the many millions of people of the allied nations devoted an entire year exclusively to hating the ____ it wouldn't kill one ___ nor shorten the war one day."

<Ha, ha> "And it might give 'em all stomach ulcers."

- Tarzan, on war

Michael Barton

This was driving me crazy and now I found out why. My colleague's new MacBook had file extensions hidden by default--even when hidden files were exposed!!!

It turns out that his text editor was adding ".txt" to all startup files and we could not see it. So .profile became .profile.txt, .bash_profile became .bash_profile.txt, etc. With this cleared up and the files renamed appropriately, we now have a workaround.

Setting LC_CTYPE and LC_ALL in .profile AND in .bash_profile ARE successful workarounds to this problem. Either one of them works.

Setting these in .grass.bashrc, .bashrc, or .grassrc6 DO NOT work.

--

Now that there is a workaround, back to the underlying problems.

I still do not know why LC_CTYPE is set for my Mac and not for his (both fairly new and running Lion). But apparently this can happen with a non-English Mac. Now we need a permanent fix so that the GUI still runs in English at least if LC_CTYPE and LC_ALL are not set. As it is, his GRASS GUI remains in English, even though his preferences--and now his LC_CTYPE and LC_ALL--are set to Spanish.

Perhaps the new preferences setting works only in Linux? Or maybe it only works if you have compiled in the relevant language? In any case, something is not quite working right with a feature that will be an excellent enhancement to the program when it IS working well.

Michael

On Jul 27, 2012, at 9:08 PM, William Kyngesburye wrote:

Set it in ~/.bash_profile, I don't think Terminal on OS X reads ~/.bashrc.

On Jul 27, 2012, at 10:45 PM, Michael Barton wrote:

Tried it. Didn't work. Any other ideas? I'm completely out of thoughts on this beyond roll back to before the change.

Michael

On Jul 27, 2012, at 7:02 PM, Hamish wrote:

Michael:

Unfortunately, putting this into .grass.bashrc doesn't work,
nor does putting this into .profile nor .grassrc6 (a long
shot).

how about exporting it in ~/.bashrc?

If put in .grass.bashrc it might only be found if you start the gui
from the GRASS> terminal prompt with g.gui, since it gets sourced late
in the game.

Hamish

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"We are at war with them. Neither in hatred nor revenge and with no particular pleasure I shall kill every ___ I can until the war is over. That is my duty."

"Don't you even hate 'em?"

"What good would it do if I did? If all the many millions of people of the allied nations devoted an entire year exclusively to hating the ____ it wouldn't kill one ___ nor shorten the war one day."

<Ha, ha> "And it might give 'em all stomach ulcers."

- Tarzan, on war

Michael Barton

Hamish noted r51822 in release branch 6 that implemented part of the language recognition change. It seems like there must be some other places where it is embedded too, because of the GUI error when LC_CTYPE is not set.

There seem to be 2 parts to the problem.

1) the way that LANG is set in .grassrc6 and in the GRASS preferences pane uses the format en_US.UTF-8. If I try to enter an alternate format (en_US or en_US.UTF8), the GUI crashes completely on launch. BUT, the proper format for LC_CTYPE in the shell and in Python (on Mac at least) is en_US.UTF8. Note the lack of a hyphen. The shell and possibly Python will also accept en_US (without any extension). The error that is coming up when LC_CTYPE is unset is that "UTF-8" is an unrecognized format. I don't know where the list of language encodings that are used in the GUI preferences and in .grassrc6 come from, but the format is a problem for Python and the shell on the Mac.

2) Here is a snippet of code from r51822

        rcfile = open(os.path.join(os.getenv('HOME'), ".grassrc6"))
   482 lines = rcfile.readlines()
   483 rcfile.close()
   484 lang = None
   485 for line in lines:
   486 if 'LANG' in line:
   487 lang = line.split(':')[1].strip()
   488 if not lang:
   489 import locale
   490 lang = '.'.join(locale.getdefaultlocale())
   491

If LANG is missing from the .grassrc6 file, this causes the entire GUI to crash for some reason. If LANG is set in .grassrc6 but LC_CTYPE and LC_ALL are not set, it causes the more insidious error that keeps the menu items from working--or perhaps it is similar code elsewhere in the GUI that is the a problem. The main problem here is "locale.getdefaultlocale()". This throws an error on non-English machines when LC_CTYPE is unset. For some reason, it is getting "UTF-8" from somewhere and doesn't recognize it in that format.

locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
ValueError: unknown locale: UTF-8

So I think there needs to be an error trap at this point for "locale.getdefaultlocale()" and a default fallback to English. One thing that I notice is that nothing seems to be reading the language setting in the wx file, where preferences sets it. I thought the idea was to make this a GUI preference. So perhaps, this also needs to be changed to read the preferences file instead of .grassrc6.

If there are other places in the GUI code that are reading the language settings, they may also need to be changed accordingly.

Michael

On Jul 27, 2012, at 11:52 PM, Michael Barton wrote:

This was driving me crazy and now I found out why. My colleague's new MacBook had file extensions hidden by default--even when hidden files were exposed!!!

It turns out that his text editor was adding ".txt" to all startup files and we could not see it. So .profile became .profile.txt, .bash_profile became .bash_profile.txt, etc. With this cleared up and the files renamed appropriately, we now have a workaround.

Setting LC_CTYPE and LC_ALL in .profile AND in .bash_profile ARE successful workarounds to this problem. Either one of them works.

Setting these in .grass.bashrc, .bashrc, or .grassrc6 DO NOT work.

--

Now that there is a workaround, back to the underlying problems.

I still do not know why LC_CTYPE is set for my Mac and not for his (both fairly new and running Lion). But apparently this can happen with a non-English Mac. Now we need a permanent fix so that the GUI still runs in English at least if LC_CTYPE and LC_ALL are not set. As it is, his GRASS GUI remains in English, even though his preferences--and now his LC_CTYPE and LC_ALL--are set to Spanish.

Perhaps the new preferences setting works only in Linux? Or maybe it only works if you have compiled in the relevant language? In any case, something is not quite working right with a feature that will be an excellent enhancement to the program when it IS working well.

Michael

On Jul 27, 2012, at 9:08 PM, William Kyngesburye wrote:

Set it in ~/.bash_profile, I don't think Terminal on OS X reads ~/.bashrc.

On Jul 27, 2012, at 10:45 PM, Michael Barton wrote:

Tried it. Didn't work. Any other ideas? I'm completely out of thoughts on this beyond roll back to before the change.

Michael

On Jul 27, 2012, at 7:02 PM, Hamish wrote:

Michael:

Unfortunately, putting this into .grass.bashrc doesn't work,
nor does putting this into .profile nor .grassrc6 (a long
shot).

how about exporting it in ~/.bashrc?

If put in .grass.bashrc it might only be found if you start the gui
from the GRASS> terminal prompt with g.gui, since it gets sourced late
in the game.

Hamish

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
grass-dev Info Page

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"We are at war with them. Neither in hatred nor revenge and with no particular pleasure I shall kill every ___ I can until the war is over. That is my duty."

"Don't you even hate 'em?"

"What good would it do if I did? If all the many millions of people of the allied nations devoted an entire year exclusively to hating the ____ it wouldn't kill one ___ nor shorten the war one day."

<Ha, ha> "And it might give 'em all stomach ulcers."

- Tarzan, on war

Michael Barton

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

Michael wrote:

So I think there needs to be an error trap at this point for
"locale.getdefaultlocale()" and a default fallback to
English.

perhaps better, fall back to "C" aka unset.

fwiw, on linux with python 2.4.4 and 2.6.6, 2.7.3, all give:

import locale
locale.getdefaultlocale()

(None, None)

lang = '.'.join(locale.getdefaultlocale())

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, NoneType found

when the parent shell has LANG=C set.

with LANG=en_US.UTF-8 at the shell, the above gives:
locale.getdefaultlocale() = ('en_US', 'UTF-8')
lang = 'en_US.UTF-8'

the tuple it returns is (language code, encoding).
  http://docs.python.org/library/locale.html

perhaps add something like:
if locale.getdefaultlocale()[0] is None:
   lang = None
else:
   lang = '.'.join(locale.getdefaultlocale())

note,
http://stackoverflow.com/questions/955986/what-is-the-correct-way-to-set-pythons-locale

so fallback to a common language setting may also have to be platform
dependent. dunno what Windows makes of LANG=C.

One thing that I notice is that nothing seems to be
reading the language setting in the wx file, where
preferences sets it. I thought the idea was to make this a
GUI preference. So perhaps, this also needs to be changed to
read the preferences file instead of .grassrc6.

sounds reasonable to me, but I wasn't following along & have not
heard it described how the new system is supposed to work.

thanks for looking into this,
Hamish

This remains puzzling. On my MacBook with Lion, I have the following:

Michaels-MacBook-Air:~ cmbarton$ echo $LC_CTYPE

Michaels-MacBook-Air:~ cmbarton$ echo $LC_ALL

Michaels-MacBook-Air:~ cmbarton$ echo $LANG
en_US.UTF-8
Michaels-MacBook-Air:~ cmbarton$ echo $LC_MESSAGE

Michaels-MacBook-Air:~ cmbarton$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import locale
locale.getdefaultlocale()

('en_US', 'UTF8')

On Carlos' MacBook with Lion (without setting LC_CTYPE in .profile), we get the following:

MacBook-Pro-de-Carlos:~ carlosrodriguezrellan$ echo $LC_CTYPE
UTF-8
MacBook-Pro-de-Carlos:~ carlosrodriguezrellan$ echo $LC_ALL

MacBook-Pro-de-Carlos:~ carlosrodriguezrellan$ echo $LANG

MacBook-Pro-de-Carlos:~ carlosrodriguezrellan$ echo $LC_MESSAGE

MacBook-Pro-de-Carlos:~ carlosrodriguezrellan$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import locale
locale.getdefaultlocale()

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
ValueError: unknown locale: UTF-8

So by default, my LANG is set but none of the other locale variables are set. For Carlos, LC_CTYPE is set (incorrectly??) and nothing else (including LANG) is set.
Neither one of us have explicitly set any of these locale variables prior to hitting this issue. Since another Spanish colleague (Agustin) also reported problems, I wonder if this is something that is "normal" for Spanish-enabled Macs.

An error trap on locale.getdefaultlocale() and setting the language explicitly in wx (rather than depending on the system locale variables), as I think the intent is, would fix this problem.

Adding an error trap to locale.getdefaultlocale() is easy (I would use try/except); fixing the GUI to use the wx configuration file instead of .grassrc6 is somewhat more labor.

MIchael

On Jul 28, 2012, at 1:08 AM, Hamish wrote:

Michael wrote:

So I think there needs to be an error trap at this point for
"locale.getdefaultlocale()" and a default fallback to
English.

perhaps better, fall back to "C" aka unset.

fwiw, on linux with python 2.4.4 and 2.6.6, 2.7.3, all give:

import locale
locale.getdefaultlocale()

(None, None)

lang = '.'.join(locale.getdefaultlocale())

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, NoneType found

when the parent shell has LANG=C set.

with LANG=en_US.UTF-8 at the shell, the above gives:
locale.getdefaultlocale() = ('en_US', 'UTF-8')
lang = 'en_US.UTF-8'

the tuple it returns is (language code, encoding).
locale — Internationalization services — Python 3.12.7 documentation

perhaps add something like:
if locale.getdefaultlocale()[0] is None:
  lang = None
else:
  lang = '.'.join(locale.getdefaultlocale())

note,
What is the correct way to set Python's locale on Windows? - Stack Overflow

so fallback to a common language setting may also have to be platform
dependent. dunno what Windows makes of LANG=C.

One thing that I notice is that nothing seems to be
reading the language setting in the wx file, where
preferences sets it. I thought the idea was to make this a
GUI preference. So perhaps, this also needs to be changed to
read the preferences file instead of .grassrc6.

sounds reasonable to me, but I wasn't following along & have not
heard it described how the new system is supposed to work.

thanks for looking into this,
Hamish

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Jul 28, 2012, at 11:56 AM, Michael Barton wrote:

So by default, my LANG is set but none of the other locale variables are set. For Carlos, LC_CTYPE is set (incorrectly??) and nothing else (including LANG) is set.
Neither one of us have explicitly set any of these locale variables prior to hitting this issue. Since another Spanish colleague (Agustin) also reported problems, I wonder if this is something that is "normal" for Spanish-enabled Macs.

Note that LANG is set automatically by Terminal.app if the Advanced preference "Set locale environment variables on startup" is checked. But, of course, this is useless if the system sets LC_CTYPE somewhere.

I have doubts that it is something specific to Spanish or other non-English systems. Others that have reported this in the past have had problems on English systems and some non-English system users have not had the problem.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"I ache, therefore I am. Or in my case - I am, therefore I ache."

- Marvin

So that means that GRASS must just deal with the possibility that locale settings might or might not be mucked up. This means that the plan to set this explicitly in the GUI is a very good way to go. It just needs to be fixed. If others are out on vacation, I might be able to fix this. But I've got 2 dissertations to read and I don't want to rush the fix and mess up something else.

Michael

On Jul 28, 2012, at 10:06 AM, William Kyngesburye wrote:

On Jul 28, 2012, at 11:56 AM, Michael Barton wrote:

So by default, my LANG is set but none of the other locale variables are set. For Carlos, LC_CTYPE is set (incorrectly??) and nothing else (including LANG) is set.
Neither one of us have explicitly set any of these locale variables prior to hitting this issue. Since another Spanish colleague (Agustin) also reported problems, I wonder if this is something that is "normal" for Spanish-enabled Macs.

Note that LANG is set automatically by Terminal.app if the Advanced preference "Set locale environment variables on startup" is checked. But, of course, this is useless if the system sets LC_CTYPE somewhere.

I have doubts that it is something specific to Spanish or other non-English systems. Others that have reported this in the past have had problems on English systems and some non-English system users have not had the problem.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"I ache, therefore I am. Or in my case - I am, therefore I ache."

- Marvin

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu