• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the default language with AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Getting the default language with AppleScript
      • From: Paul Berkowitz <email@hidden>
    • Re: Getting the default language with AppleScript
      • From: Emmanuel <email@hidden>
References: 
 >Re: Getting the default language with AppleScript (From: Emmanuel <email@hidden>)

  • Prev by Date: Re: Sorting a list of Lists
  • Next by Date: Re: Characters in a file name - some progress
  • Previous by thread: Re: Getting the default language with AppleScript
  • Next by thread: Re: Getting the default language with AppleScript
  • Index(es):
    • Date
    • Thread