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
>>> 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
> 
> 
> 

_____________________
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

Reply via email to