Re: Getting the default language with AppleScript
Re: Getting the default language with AppleScript
- Subject: Re: Getting the default language with AppleScript
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 24 Jul 2004 10:44:26 -0700
It's odder than that. I had him do a
defaults find Locale
and now the result is
jack% defaults find Locale
Found 1 keys in domain 'Apple Global Domain': {AppleLocale = "en_US"; }
exactly as it should be.
So I had him try
defaults read 'Apple Global Domain' AppleLocale
defaults read -g AppleLocale
again, and now he does get
en_US
At one point I had him go look at his International System prefs. He didn't
change anything, but maybe just going there got it working. Highly
mysterious. If anyone ever reports this again, I'll check that out. Maybe a
simple log out and log in would help too. Very strange.
--
Paul Berkowitz
>
From: Paul Skinner <email@hidden>
>
Date: Sat, 24 Jul 2004 11:02:59 -0400
>
To: <email@hidden>
>
Subject: Re: Getting the default language with AppleScript
>
>
When I create a new user 'raw' and immediately run the command...
>
titan:~ raw$ defaults read -g
>
>
I get...
>
>
{
>
AppleAntiAliasingThreshold = 8;
>
AppleLanguages = (en, ja, fr, de, es, it, nl, sv, no, da, fi, pt,
>
"zh_CN", "zh_TW", ko);
>
AppleLocale = "en_US";
>
}
>
>
This is on System Version: Mac OS X 10.3.4 (7H63). I don't know how
>
your friend has managed to get by without it. I get the result you
>
listed if I mistype 'locale' as 'locales' or otherwise screw up the
>
domain. Typo?
>
>
Various pertinent bits...
>
Though all applications, system services, and other programs have their
>
own domains, they also share a domain named NSGlobalDomain. If a
>
default isn't specified in the application's domain, but is specified
>
in NSGlobalDomain, then the application uses the value in that domain.
>
...
>
Another NSGlobalDomain default, under the key AppleLanguages, allows
>
users to specify a preference of languages as an array of strings. For
>
example, a user could specify English as the preferred language,
>
followed by Spanish, French, German, Italian, and Swedish.
>
...
>
If a user has a value for the AppleLanguages default, then
>
NSUserDefaults records language-specific default values in domains
>
identified by the language name. The language specific domains contain
>
defaults for a locale.
>
>
But I don't find any domain identified by the language name en_US.
>
>
Paul
>
>
On Jul 23, 2004, at 11:10 PM, Paul Berkowitz wrote:
>
>
> A couple of weeks ago we worked out that in Panther, you can get the
>
> user's
>
> default language (formerly 'system attribute "LANG"' in Jaguar and
>
> earlier)
>
> by
>
>
>
> do shell script "defaults read -g AppleLocale"
>
>
>
> (or rather the bit before the "_" if it has a "_").
>
>
>
> But now I've discovered that a friend, also in OS 10.3.4 like I am,
>
> has no
>
> global AppleLocale default entry at all, and that command errors:
>
>
>
> "The domain/default pair of (kCFPreferencesAnyApplication,
>
> AppleLocale)
>
> does not exist."
>
>
>
> I had him do a
>
>
>
> defaults read -g
>
>
>
> both via AppleScript and in the Terminal (different shells), and the
>
> very
>
> long list of defaults contained no AppleLocale.
>
>
>
> I had him check System Preferences/International/Formats and his is
>
> set to
>
> "United States". (Even when I changed mine to "Custom", logged out and
>
> in,
>
> I still got "en_US" for mine.) He has BSD installed normally.
>
>
>
> Does anyone know what condition results in an AppleLocale, and what
>
> doesn't?
>
> And if one can make any deduction as to locale if one doesn't have a
>
> globalDomain AppleLocale?
>
>
>
>
>
> Paul Berkowitz
>
>
>
>
>
>
>
> On 7/7/04 9:13 AM, "Paul Berkowitz" <email@hidden> wrote:
>
>
>
>>> At 9:27 AM -0400 06/07/04, Alexandre Koff wrote:
>
>>>> I was just wondering if anyone knows how to get the user's default
>
>>>> language using AppleScript. I was reading through the AppleScript
>
>>>> documentation on developer.apple.com but it seems to be a bit
>
>>>> lacking.
>
>>>
>
>>> Sorry if this has been said already, but I use:
>
>>>
>
>>> -------------
>
>>> system attribute "LANG"
>
>>
>
>> That works in Jaguar (where I used to use it myself, as I said
>
>> earlier) but
>
>> not in Panther, where all this has been changed utterly.
>
>>
>
>> system attribute "LANG" -- in OS 10.3.4
>
>> --> ""
>
>>
>
>> So it's just a matter of doing a 'system attribute "sysv"' first.
>
>>
>
>> The same thing can be done in plain AppleScript using:
>
>>
>
>> set AppleScript's text item delimiters to {"_"}
>
>> if (system attribute "sysv") < 4144 then
>
>> set lang to text item 1 of (system attribute "LANG")
>
>> else
>
>> set lang to text item 1 of (do shell script "defaults read -g
>
>> AppleLocale")
>
>> end if
>
>> set AppleScript's text item delimiters to {""}
>
>> lang
>
>> -- "en" -- here
>
>
>
>
>
> --
>
> Paul Berkowitz
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.