Here is the announced script.
I dropped the enclosing asterisks so I may search more easily the location of the inserted date.
--
--[SCRIPT openAndInsertFrenchDate]
(*
Enregistrer le script en tant que Script : openAndInsertFrenchDate.scpt
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Pages:
Il vous faudra peut-être créer le dossier Pages et peut-être même le dossier Applications.
menu Scripts > Pages > openAndInsertFrenchDate
crée un nouveau document à partir du modèle personnel prédéfini
et remplace les mots "mytFakeDate" par la date en Français.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
+++++++
Save the script as Script, Application or Application Bundle: openAndInsertFrenchDate.xxx
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Pages:
Maybe you would have to create the folder Pages and even the folder Applications by yourself.
menu Scripts > Pages > openAndInsertFrenchDate
will create a new document from the defined user template
and replace every words "myFakeDate" by the date in French.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
--=====
Yvan KOENIG (VALLAURIS, France)
2010/01/09
*)
property theApp : "Pages"
property theMonths : {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}
property theDays : {"lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"}
property balise : "myFakeDate" (* CAUTION? You may change it but, it MUST be a word *)
property avecNomJour : true
(*
true : inserts the name of the day before the date
false : doesn't insert the name of the day before the date
*)
--=====
on run
set p2myTemplate to my prepare()
set FrenchDate to my dateEnFrancais()
set UNTITLED_loc to my getLocalizedFrameWorksName(theApp, "Untitled")
tell application theApp
activate
try
close document UNTITLED_loc
end try
end tell -- theApp
tell application theApp
activate
open p2myTemplate
tell document 1
set n to count of words
repeat with P from n to 1 by -1
if word P is balise then set word P to FrenchDate
end repeat
end tell -- document
end tell -- theApp
end run
--=====
on dateEnFrancais()
local dd, francais, w, j
set dd to current date
set francais to "" & (day of dd) & space & item (month of dd as number) of theMonths & space & year of dd
if avecNomJour then
set w to (weekday of dd) as text
set w to text 1 thru 3 of w
repeat with j from 1 to 7
if w = item j of {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"} then
set w to item j of theDays
exit repeat
end if -- w = item j…
end repeat
set francais to w & space & francais
end if -- avecNomJour
return francais
end dateEnFrancais
--=====
on getLocalizedFrameWorksName(theApp, x)
local p2bndl
set p2bndl to (path to application support as text) & "iWork '09:Frameworks:SFApplication.framework:Versions:A:Resources:"
return my getLocalizedName(theApp, x, p2bndl)
end getLocalizedFrameWorksName
--=====
on getLocalizedName(aa, tt, ff)
tell application aa to return localized string tt from table "Localizable" in bundle file ff
end getLocalizedName
--=====
on prepare()
local d1, d2, customTemplateFolder
tell application theApp
set d1 to localized string "Templates" (* nom local du dossier "Modèles" *)
set d2 to localized string "My Templates" (* nom local du dossier "Mes Modèles" *)
end tell -- theApp
set customTemplateFolder to (((path to application support from user domain) as Unicode text) & "iWork:" & theApp & ":" & d1 & ":" & d2 & ":") as alias
return choose file default location customTemplateFolder without invisibles
end prepare
--=====
--[/SCRIPT]
--
Yvan KOENIG (VALLAURIS, France) samedi 9 janvier 2010 18:59:40