• 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: Two quick questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two quick questions


  • Subject: Re: Two quick questions
  • From: kai <email@hidden>
  • Date: Sat, 24 Mar 2007 01:18:04 +0000


On 23/03/2007, at 11:00, Bryan Lockwood wrote:

1. How do I get the version of the OS?

In addition to the methods already suggested, the 'system info' command also has a 'system version' property - although it doesn't really help if one is trying to check for pre-Tiger OS versions:


----------------

set OS_version to system version of (system info)

----------------

The question is whether the version in hexadecimal form is really required for the job in hand. If not, <system attribute "sysv"> (already mentioned) is fast, has a long legacy - and, as a numerical value, is more versatile in terms of matching a version range.

A common need for such information is, for example, to determine whether the OS version is equal to or greater than a given value. In such cases, the raw number could simply be used to make a direct comparison:

----------------

set Tiger to (system attribute "sysv") > 4159 -- 4160 <—> "10.4.0"

----------------

One might even use the number to do stuff like:

----------------

set version_name to item ((system attribute "sysv") mod 4096 div 16 + 1) ¬
of {"Cheetah", "Puma", "Jaguar", "Panther", "Tiger", "Leopard"}


----------------

2. How do I most reliably ascertain the local language. I say that because
I've been using something like:


    set lang to user locale of (system info)

This apparently works fine, or at least I thought so, returning things like
"en_us" or "de_de"; however, lately it's not tracking too well. Currently
I'm set up for German, and in fact all the menus etc. are appearing in
German, only my technique is still returning "en_us". This is the case on at
least two of my machines, so I'm thinking that there must be a better way.

The user locale property returned by the 'system info' command reflects the current date/time/number format settings. If a change is made to the primary language, but not to the format settings, then the user locale property would normally remain unchanged.


The same would be true if we were to extract a similar value from the property list file:

----------------

tell application "System Events" to set current_locale to value of ¬
	property list item "AppleLocale" of property list file ¬
	(preferences folder's path & ".GlobalPreferences.plist")

----------------

However, the primary language could be determined using another property list item from the same property list file:

----------------

tell application "System Events" to set current_language to value of ¬
property list item 1 of property list item "AppleLanguages" of ¬
property list file (preferences folder's path & ".GlobalPreferences.plist")


----------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Two quick questions (From: Bryan Lockwood <email@hidden>)

  • Prev by Date: Re: Two quick questions
  • Next by Date: Costa Bugg is out of the office.
  • Previous by thread: Re: Two quick questions
  • Next by thread: Re: Two quick questions
  • Index(es):
    • Date
    • Thread