• 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: Preferences and l10n
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preferences and l10n


  • Subject: Re: Preferences and l10n
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 17 May 2015 16:49:36 +0200


Le 17/05/2015 à 15:08, Jean-Christophe Helary <email@hidden> a écrit :

The script I've been working on recently work fine for me, but I'd like to make it into something that can work on somebody else's machine.

For that I guess I need 2 things:
1) extract all "local" information (like paths etc) and put them in a preference file
2) create localized versions

Is there a reference somewhere about the 2 above topics ?

Jean-Christophe Helary

I don't understand what is the need for localized pathnames.
AppleScript don't use them.

If my memory is not too bad, it seems that I already wrote about that here.


The finder displays my user library folder by :

"SSD 500 > Utilisateurs > [my account] > Bibliothèque

But for Applescript the Hfs pathname is :

"SSD 500:Users:[my account]:Library:"

and the Posix one is:

"/Users/[my account]/Library/"

Last not least, when triggering directly the Unix side of the system the same path may be written

~/Library/

As you see, none of these path embed "Utilisateurs" or "Bibliothèque"

If the well known pid headed user try to use the "french" pathname he see :

tell application "Finder"
set leDossier to folder "SSD 500:Utilisateurs: [my account] :Bibliothèque"
end tell

log leDossier --> (*folder Library of folder  [my account]  of folder Users of startup disk*)
leDossier as alias --> alias "SSD 500:Users: [my account] :Library:"

As the same user hate to speak to Finder he would try to use :

tell application "System Events"
set leDossier to folder "SSD 500:Utilisateurs: [my account] :Bibliothèque"
end tell

And the result would be:

error "Erreur dans System Events : Il est impossible d’obtenir folder \"SSD 500:Utilisateurs: [my account] :Bibliothèque\"." number -1728 from folder "SSD 500:Utilisateurs: [my account] :Bibliothèque"

To be short, when we speak to AppleScript the best thing to  do is to forget the localized pathname.
CAUTION, it's important to know that several properties of files/folders etc may be localized and it's the source of some questions asked from time to time.


I wish to add some words about a not so old question.
You asked  if there is a way to do that :

return index of (month of my_date) in {list of months contants}

There is no pre-built list of months names.
If you want one, you must built it:

set monthsNames to {}
"11/11/11"
set aDate to date result
repeat with m from 1 to 12
set month of aDate to m
set end of monthsNames to month of aDate
end repeat
monthsNames
--> {January, February, March, April, May, June, July, August, September, October, November, December}

As our brave old AppleScript is unable to return index of anItem in aLisOfItems, when we were young we used : 

set theMonths to "123JanFebMarAprMayJunJulAugSepOctNovDec"
(get month of (current date)) as text
text 1 thru 3 of result
set monthIndex to (offset of result in theMonths) div 3

Emmanuel, the Smile evangelist, offered an alternate scheme using only arithmetic operations but I was never able to remember it.

Happily, somebody in the AppleScript team was fair enough to add the ability to grab the month of a date as a numerical value but he was so shy that if my memory is right he didn't wrote that in AppleScript User Guide.
I'm to lazy to search in my archives to check if at least this "new" feature is described i an AppleScript release note but as you were able to see in the late Luther's answer, it really works.


Yvan KOENIG (VALLAURIS, France) dimanche 17 mai 2015 16:49:31




 _______________________________________________
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

  • Follow-Ups:
    • Re: Preferences and l10n
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Preferences and l10n (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: month contants and dates...
  • Next by Date: Re: Preferences and l10n
  • Previous by thread: Preferences and l10n
  • Next by thread: Re: Preferences and l10n
  • Index(es):
    • Date
    • Thread