Re: Rép: reading a property list item
Re: Rép: reading a property list item
- Subject: Re: Rép: reading a property list item
- From: Ed Stockly <email@hidden>
- Date: Tue, 20 May 2008 09:05:29 -0700
Maybe I'm not understanding this, but what is the purpose of reading
from a file? That seems to be building an instability in your script
that will come back to haunt you. Especially since you're reading
from two different files used for different purposes.
I tried running your script on my mac and I got the days of the week
for each language but only the month for English.
Since you can learn all the names of the days and months and those
names don't change, why not just hard code them into your script, as
you do with the English months?
Something like the script below would be bulletproof. You wouldn't
need to worry about what was installed on the mac, or depend on the
same files being in the same places with the same content through
various upgrades, etc.
You could include it as a library in your script bundle, or simply
add it as a handler to your script.
Although speed is probably not an issue, this would run faster that
yours. It would also be pretty simple to write a routine that would
gather the names of the days and months without having to type them in.
HTH,
ES
---------
set dd to "1/12/2008"
repeat with x from 1 to 14
set ladate to my traduitLaDate(dd, x)
end repeat
on traduitLaDate(d, lang)
local nomsDesMois, nomsDesJours, ladate, numJour, annee, nomJour,
itemNomJour, itemNomMois, laLangue, p2a, nomDuJour, nomDuMois
set allLang to {}
set the end of allLang to {"da", {"JANUARY", "FEBRUARY", "MARCH",
"APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
"NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}}
set the end of allLang to {"Dutch", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"English", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"fi", {"JANUARY", "FEBRUARY", "MARCH",
"APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
"NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}}
set the end of allLang to {"French", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"German", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"Italian", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"Japanese", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"ko", {"JANUARY", "FEBRUARY", "MARCH",
"APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
"NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}}
set the end of allLang to {"no", {"JANUARY", "FEBRUARY", "MARCH",
"APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
"NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}}
set the end of allLang to {"Spanish", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"sv", {"JANUARY", "FEBRUARY", "MARCH",
"APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
"NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}}
set the end of allLang to {"zh_CN", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set the end of allLang to {"zh_TW", {"JANUARY", "FEBRUARY",
"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
"OCTOBER", "NOVEMBER", "DECEMBER"}, {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"}}
set {laLangue, theseMonths, theseDays} to item lang of allLang
try
set ladate to date d
on error
return d as text
end try
set numJour to day of ladate
set annee to year of ladate
set nomDuJour to (weekday of ladate) as integer
set nomDuMois to (month of ladate as integer)
try
set nomDuJour to item nomDuJour of theseDays
set nomDuMois to item nomDuMois of theseMonths
on error
--what could go wrong?
end try
return (nomDuJour & ", " & numJour & " " & nomDuMois & " " &
annee) as text
end traduitLaDate
_______________________________________________
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