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: Wed, 07 Jul 2004 09:13:58 -0700
On 7/7/04 6:52 AM, "Emmanuel" <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
--> ""
>
-------------
>
>
and then I take whatever precedes an underscore (or the whole string if
>
there's no underscore). Which gives:
>
>
-------------
>
find text "^[^_]+" in (system attribute "LANG") with regexp and string result
That Satimage grep would work well in Panther as
find text "^[^_]+" in (do shell script "defaults read -g AppleLocale") with
regexp and string result
So it's just a matter of doing a 'system attribute "sysv"' first:
if (system attribute "sysv") < 4144 then
find text "^[^_]+" in (system attribute "LANG") with regexp and string
result
else
find text "^[^_]+" in (do shell script "defaults read -g AppleLocale")
with regexp and string result
end if
-- "en" -- here
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.