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: KOENIG Yvan <email@hidden>
- Date: Wed, 21 May 2008 11:24:05 +0200
Le 21 mai 2008 à 06:32, Mark J. Reed a écrit :
if I might suggest a Perly partial solution, this will get you a list
of month and day names in any POSIX locale installed on your system:
set pourLocale to "nl_NL"
set nomsDesMois to paragraphs of (do shell script "LC_TIME=" & quoted
form of pourLocale & " perl -MPOSIX -le 'for ($m=0;$m<12;++$m) { print
strftime(\"%B\", 0, 0, 12, 15, $m, 100) }' ")
set nomsDesJours to paragraphs of (do shell script "LC_TIME=" & quoted
form of pourLocale & " perl -MPOSIX -le 'for ($d=0;$d<7;++$d) { print
strftime(\"%A\", 0, 0, 12, $d, 0, 101) }' ")
This will get you a list of the available locale names:
set locales to paragraphs of (do shell script "locale -a")
although that includes some that differ only in character set; you
probably don't care about those differences, so this gets you a
shorter list of just the simple locale names:
set locales to paragraphs of (do shell script "locale -a | grep -v
'\\.'")
The names are all ab_XY where "ab" is the ISO 2-letter language code
and "XY" is the ISO 2-letter country code. es_ES is Spanish as she is
spoke in Spain; en_US is US English; fr_CA is Quebecois; etc.
Thank you Mark
I was sure that the names where stored somewhere, at least for the
system usage but I didn't know where.
Of course it's better that grabbing them from the DateAndTime
prefPane and from iTunes even if these two items are installed on
every machine.
The main files are installed but of course, the user may have, like
me, removed some resources files.
And may I add that I am glad to read that my question get a response
using perl even if my named ruby in a recent message ;-)
--(SCRIPT dateToDutch.app]
(*
Enregistrer le script en tant qu'Application ou Progiciel :
dateToDutch.app
déplacer l'application créée dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Nu
mbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être
même le dossier Applications.
Copier les dates à traduire dans le presse-papiers.
Pour obtenir un résultat correct les dates de départ doivent
utiliser l'année en quatre chiffres
Vous pouvez travailler sur plusieurs colonnes.
Placez le curseur où ça vous chante dans Numbers
menu Scripts > dateToDutch
Le script collera les dates traduites.
+++++++++
Save the script as an Application or an Application Bundle:
dateToDutch.app
Move the newly created application into the folder:
<startup
Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder
Applications by yourself.
Copy the dates to translate in the clipboard.
To get correct results, original dates must use four digits year.
You may work with several colums.
Put the cursor where you wish in Numbers
menu Scripts > dateToDutch
The script will paste the translated dates.
Yvan KOENIG le 20 mai 2008
revisé le 21 mai. Thanks to Mark J. Reed
*)
property lignesAvant : missing value
property lignesApres : missing value
property listeCells : missing value
property r : missing value
property nomsDesMois : missing value
property nomsDesJours : missing value
property theApp : "Numbers"
property usePaste : true (*
• false = keystroke the dates
true = paste the dates
Paste the dates works with every languages *)
on run
try
set txtDatas to the clipboard as Unicode text
on error (*
• The clipboard was empty *)
return
end try
my nettoie()
set my lignesAvant to paragraphs of txtDatas
if nomsDesMois is missing value then my recupLesNoms("nl_NL")
if txtDatas contains tab then
repeat with n in my lignesAvant
set my listeCells to my decoupe(n, tab)
set my r to {}
repeat with i from 1 to count of my listeCells
copy my traduitLaDate(item i of my listeCells) to end of my r
end repeat
copy my recolle(my r, tab) to end of my lignesApres
end repeat
else
repeat with n in my lignesAvant
copy my traduitLaDate(n) to end of my lignesApres
end repeat
end if
if usePaste is true then
set the clipboard to (my recolle(my lignesApres, return)) as text
tell application theApp to activate
tell application "System Events" to tell (first process whose title
is theApp) to keystroke "v" using {command down}
else
set les_dates to my recolle(my lignesApres, return)
tell application theApp to activate
tell application "System Events" to tell (first process whose title
is theApp) to keystroke les_dates
end if
my nettoie()
end run
--=============
on traduitLaDate(d)
local ladate, numDuJour, nomJour, nomDuJour, nomDuMois, |année|, dd
try
set ladate to date d
set numDuJour to (day of ladate)
set nomDuJour to (item (weekday of ladate) of nomsDesJours) as text
set nomDuMois to (item (month of ladate as number) of nomsDesMois)
set |année| to (year of ladate)
set dd to (nomDuJour & ", " & numDuJour & " " & nomDuMois & " " & |
année|) as text
on error
set dd to d as text
end try
return dd
end traduitLaDate
--=============
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=============
on recolle(l, d)
local t
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to ""
return t
end recolle
--=============
on nettoie()
set my lignesAvant to {}
set my lignesApres to {}
set my listeCells to {}
set my r to {}
end nettoie
--=============
on recupLesNoms(pourLocale)
(* available languages:
af_ZA, am_ET, be_BY, bg_BG, ca_ES, cs_CZ, da_DK, de_AT, de_CH, de_DE,
el_GR, en_AU, en_CA, en_GB, en_IE, en_NZ, en_US, es_ES, et_EE, eu_ES,
fi_FI, fr_BE, fr_CA, fr_CH, fr_FR, he_IL, hr_HR, hu_HU, hy_AM, is_IS,
it_CH, it_IT, lt_LT, nl_BE, nl_NL, no_NO, pl_PL,
pt_BR, pt_PT, ro_RO, sk_SK, sl_SI, sv_SE, tr_TR,
available but odd results with keystroke
ja_JP, kk_KZ, ko_KR, sr_YU, uk_UA, ru_RU, zh_CN, zh_HK, zh_TW
*)
set nomsDesMois to paragraphs of (do shell script "LC_TIME=" &
quoted form of pourLocale & " perl -MPOSIX -le 'for ($m=0;$m<12;++$m)
{ print strftime(\"%B\", 0, 0, 12, 15, $m, 100) }' ")
set nomsDesJours to paragraphs of (do shell script "LC_TIME=" &
quoted form of pourLocale & " perl -MPOSIX -le 'for ($d=0;$d<7;++$d)
{ print strftime(\"%A\", 0, 0, 12, $d, 0, 101) }' ")
end recupLesNoms
--=============
--[/SCRIPT]
Yvan KOENIG (from FRANCE mercredi 21 mai 2008 11:24:00)
_______________________________________________
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