• 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: email@hidden
  • Date: Tue, 6 Jul 2004 19:35:15 -0400

As per Peter Fischer:

do shell script "defaults read com.apple.dock loc"

... is correct - to determine the current logged in 'default language'.

If one were to go to the 'System Preferences' 'International' Utility's 'Language' tab and place 'Deutsch' above 'English', the above 'do shell script' code would still return 'en_US', however.
Regardless of quitting 'Script Editor' and / or re-launching 'Finder' via 'Force Quit' or 'TinkerTool', the above 'do shell script' code would return 'en_US'.

The only way to reflect the change is either to log out and log back in, or quite simply quit the 'Dock'. Sadly, the 'Dock' will automatically reappear. However, running the above 'do shell script' would then correctly display the newly chosen 'default language'. Sometimes I would have to run the above code twice before the recently changed to language was properly returned.

Thus, I created the following code ...

tell application "Dock" to quit

tell application "System Events"
repeat until (process "Dock" exists)
end repeat
end tell

delay 5
do shell script "defaults read com.apple.dock loc"

... which always produces the current 'default language' setting, at least here* it does.

* dual 500 MHz G4 PPC PM, MacOS X 10.3.4, Script Editor 2.0.

To test the above code I dragged 'Deutsch' to the top of the 'System Preferences' 'International' Utility's 'Language' list, and then ran the provided code, obtaining the expected results. Next I dragged 'English' to the top, ran the code - and again received the correct result; then again with 'Deutsch' ... - each time the code displayed the correct 'default language' setting.

I am sure someone may be able to write even simpler and more efficient code.

-----

do shell script "defaults read com.apple.systempreferences AppleIntlCustomFormat"

... does not reflect the current logged in 'default language' [set via the 'System Preferences' 'International' Utility's 'Language' tab settings]; but, the settings of the 'System Preferences' 'International' Utility's 'Formats' tab's 'Region' popup menu, 'Dates' 'Customize...' button, 'Times' 'Customize...' button, 'Numbers' 'Customize...' button, and the 'Measurements Units' popup menu.

-----

Please note that the 'loc' key is only listed in the 'com.apple.dock.plist' file of the user who the Mac booted to. That is, while other logged in users also have a 'com.apple.dock.plist' file; their 'com.apple.dock.plist' file will not contain a 'loc' key-value pair. Again, that is how it is - here.

--

SJWL
_______________________________________________
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: Martin Orpen <email@hidden>
  • Prev by Date: Re: Script breaks when launched from Mail script menu, fine in SE
  • Next by Date: Re: Getting the default language with AppleScript
  • Previous by thread: Re: Getting the default language with AppleScript
  • Next by thread: Re: Getting the default language with AppleScript
  • Index(es):
    • Date
    • Thread