Auto date and time in different languages

Hi there

I have set up templates for French and English correspondence. I would like to use the insert date function in the templates. However, even if I define the text language as French, the auto date function is inevitably English. Is there any way to get around this? Or am I stuck with manually typing in dates?

Thanks

MacBook, Mac OS X (10.5.6)

Posted on Feb 8, 2009 8:32 AM

Reply
12 replies

Feb 8, 2009 8:39 AM in response to kiwilegal

You are stuck or you do what I does.

You uncheck every languages minus French and English in the list of languages available in the Pages infos window.

When you want to work in French, uncheck English, when you want to work in English, uncheck French.

An alternate soluce is to define two user account. One with the system's language set to French and from this account Pages will automatically run in French.
The second one set to English and from this account Pages will run in English.

Don't worry.

If you prefer you may set the first one to English and the second one to French 😉

Yvan KOENIG (from FRANCE dimanche 8 février 2009 17:39:12)

Feb 8, 2009 9:05 AM in response to kiwilegal

Non, le système n'y changera rien.

C'est le programme qui est conçu pour utiliser le format de date du système.

Mais il y a des solutions.
On peut parfaitement imaginer un "Service" insérant la date dans un format différent du format système.

Je vais concocter un script le faisant.
J'ai juste besoin de savoir quel est le langage utilisé par défaut par votre système afin de coder l'utilisation du langage complémentaire.

Mais, entre nous, le plus simple serait d'adopter une bonne fois le format ISO

yyyy-mm-dd 😉

Yvan KOENIG (from FRANCE dimanche 8 février 2009 18:05:05)

Feb 8, 2009 10:27 AM in response to kiwilegal

Emballez, c'est pesé.

Si vous ne voulez pas du nom du jour, remplacez:

property avecNomJour : true
par
property avecNomJour : false

--(SCRIPT dateEnFrancais.app]

(*
Enregistrer le script en tant qu'Application ou Progiciel : dateEnFrançais.app
déplacer l'application créée 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.
Placez le curseur à votre guize
menu Scripts > Pages > dateEnFrançais
Le script insérera la date à l'emplacement du curseur.
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 an Application Bundle: dateEnFrançais.app
Move the newly created application 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.
Now, enter your Pages document and put the cursor where you want to insert the date.
Go to
menu Scripts > dateEnFrançais
The script will insert the date in the Pages document.
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)
8 février 2009
*)
property avecNomJour : true
set laDate to my dateFrancaise(current date)
tell application "Pages" to tell document 1 to set selection to laDate
--=====
on dateFrancaise(dd)
local francais, w
set francais to "" & (day of dd) & space & item (month of dd as number) of {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} & 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 {"lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"}
exit repeat
end if
end repeat
set francais to w & space & francais
end if
return francais
end dateFrancaise
--=====
--[/SCRIPT]


Yvan KOENIG (from FRANCE dimanche 8 février 2009 19:25:23)

Feb 8, 2009 1:37 PM in response to Sébastien Menu

éditez

property avecNomJour : true

en
property avecNomJour : false

puis éditez la ligne:

set francais to "" & *(day of dd) & space &* item (month of dd as number) of {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} & space & year of dd

comme suit:

set francais to "" & item (month of dd as number) of {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} & space & year of dd

Yvan KOENIG (from FRANCE dimanche 8 février 2009 22:37:32)

Feb 11, 2009 3:32 AM in response to KOENIG Yvan

Enhanced version.

Now it may be encapsulated in a Service.

--(SCRIPT dateEnFrancais.app]

(*
Enregistrer le script en tant qu'Application ou Progiciel : filter on column.app
déplacer l'application créée 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.
Placez le curseur à votre guise
menu Scripts > Pages > dateEnFrancais
Le script insérera la date à l'emplacement du curseur.
--=====
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".
-- NOUVEAU NOUVEAU NOUVEAU
Grace au programme gratuit ThisService, il est possible d'encapsuler ce script dans un service.
Télécharger ThisService depuis:
http://wafflesoftware.net/thisservice/
Lors de la création du service, cliquer le bouton "Produce output".
Il est possible d'associer un raccourci clavier au service.
+++++++
Save the script as an Application Bundle: dateEnFrancais.app
Move the newly created application 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.
Now, enter your Pages document and put the cursor where you want to insert the date.
menu Scripts > Pages > dateEnFrancais
The script will insert the date in the Pages document.
--=====
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.
-- NEW NEW NEW NEW
Thanks to the free program ThisService, we may encapsulate this script in a Service.
Download ThisService from
http://wafflesoftware.net/thisservice/
When creating the service click the button "Produce output"
We may link the service to a shortcut.
+++++++
Yvan KOENIG (Vallauris FRANCE)
8 février 2009
10 février 2009
*)
property avecNomJour : true
--=====
on run {}
set rezult to my main()
tell application "Pages" to tell document 1 to set selection to rezult
end run
--=====
on process()
set rezult to my main()
return rezult
end process
--=====
on main()
local francais, w, dd
set dd to current date
set francais to "" & (day of dd) & space & item (month of dd as number) of {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} & 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 {"lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"}
exit repeat
end if
end repeat
set francais to w & space & francais
end if
return francais
end main
--=====
--[/SCRIPT]


Yvan KOENIG (from FRANCE mercredi 11 février 2009 12:32:31)

Mar 17, 2009 3:15 PM in response to Sébastien Menu

Réponse claire et nette: NON

Il n'y a pas d'objet de ce type dans Pages.

Par contre il est possible d'écrire un script qui serait utilisé pour créer un nouveau document à partir d'un modèle (éventuellement prédéfini ou sélectionné par un dialogue choose file) et pourrait insérer l'information.

Maintenant je débranche, je lirais votre réponse éventuelle demain.

Yvan KOENIG (from FRANCE mardi 17 mars 2009 23:15:05)

Mar 19, 2009 1:28 AM in response to KOENIG Yvan

If the problem is to insert automatically the current date given the system settings here is a neat soluce giving to all of us a feature used by in thebox templates.

--[SCRIPT change2oneShotTemplate]

(*
Save the script as an Application (Application Bundle if you want to use it on a MacIntel)
Store it on the Desktop.
Create a document matching your default requirements.
Insert DateTime where you want.
Double click the inserted date to adjust the format as you want.
IMPORTANT: check the box entitled "Automatically update on open"
Save your document.
Drag and drop its icon on the script icon.
You may also double click the script's icon then navigate to select the document.
The script will replace the item:
"sf:auto-update=" by the alternate one "sf:one-shot=".
This one is used by Apple in the inthebox template but there is no GUI available to allow us to insert it.
When it is set to true, "sf:auto-update=" insert the current date time but it's a live one which will change each time you will open the created standard document.
When it is set to true, "sf:one-shot=" insert the current date time but it's a fixed one which will not change when you will re-open the created standard document.
Yvan KOENIG (Vallauris, FRANCE)
18 mars 2009
*)
property permittedK4 : {"com.apple.iWork.keynote.sffkey"}
property permittedK5 : {"com.apple.iwork.keynote.key"}
property permittedKey : permittedK5 & permittedK4
(* Keynote documents are treated differently *)
property permitted4 : {"com.apple.iWork.pages.sffpages", "com.apple.iwork.numbers.sffnumbers"} & permittedK4
property permitted5 : {"com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers"} & permittedK5
property permitted : permitted5 & permitted4
property typeID : missing value
--=====
on run (*
lignes exécutées si on double clique sur l'icône du script application
• lines executed if one double click the application script's icon *)

tell application "System Events"
if my parleAnglais() then
set myPrompt to "Choose an iWork’s document"
else
set myPrompt to "Choisir un document iWork"
end if -- parleAnglais

if 5 > (system attribute "sys2") then (*
if Mac Os X 10.4.x *)
set allowed to my permitted
else (*
it's Mac OS X 10.5.x with a bug with Choose File *)
set allowed to {}
end if -- 5 > (system…
my commun(choose file with prompt myPrompt of type allowed) (* un alias *)
end tell
end run
--=====
on open (sel) (*
sel contient une liste d'alias des élémentsqu'on a déposés sur l'icône du script (la sélection)
• sel contains a list of aliases of the items dropped on the script's icon (the selection) *)

my commun(item 1 of sel) (* an alias *)
end open
--=====
on commun(thePack) (*
• thePack is an alias *)
local pFold, pName, path2Index, texteXML
my nettoie()
tell application "System Events" to tell disk item (thePack as text)
set typeID to (type identifier) as text
set pFold to package folder
set pName to name
end tell

if typeID is not in my permitted then
if my parleAnglais() then
error "“" & (docIwork as text) & "” is not an iWork’s document!"
else
error "«" & (docIwork as text) & "» n’est pas un document iWork !"
end if -- my parleAnglais()
end if -- typeID

if pFold then my expandFlat(thePack) (* an alias *)

try
if typeID is in my permittedKey then (*
special case Keynote *)
set path2Index to (thePack as text) & "Index.apxl"
else (*
Pages or Numbers *)
set path2Index to (thePack as text) & "Index.xml"
end if -- typeID starts …

set texteXML to my lis_Index(path2Index)

set texteXML to my decoupe(texteXML, "sf:auto-update=")
if (count of texteXML) > 1 then
repeat with i from 2 to count of texteXML
set itmI to item i of texteXML
if itmI starts with "false" then set item i of texteXML to "true" & text 6 thru -1 of itmI
end repeat
end if -- count of
set texteXML to my recolle(texteXML, "sf:one-shot=")

my enregistre(texteXML, path2Index)

my changeDoc2template(thePack) (* an alias *)

on error error_message number error_number
my nettoie()
if error_number is not -128 then my affiche(error_message)
end try
my nettoie()
end commun
--=====
on nettoie()
set typeID to missing value
end nettoie
--=====
on affiche(msg)
tell application "Finder"
activate
if my parleAnglais() then
display dialog msg buttons {"Cancel"} default button 1 giving up after 120
else
display dialog msg buttons {"Annuler"} default button 1 giving up after 120
end if -- parleAnglais()
end tell -- application
end affiche
--=====
on lis_Index(cheminXML0)
local cheminXML0, cheminXMLgz, txtXML
set cheminXMLgz to cheminXML0 & ".gz"

tell application "System Events"
if exists file cheminXMLgz then
if exists file cheminXML0 then delete file cheminXML0 (*
un curieux a pu dé-gzipper le fichier
• someone may have gunzipped the file *)
my expand(cheminXMLgz)
set txtXML to my lisIndex_xml(cheminXML0)
else if exists file cheminXML0 then
set txtXML to my lisIndex_xml(cheminXML0)
else
if typeID is in my permittedKey then (*
special case Keynote *)
if my parleAnglais() then
error "Index.apxl missing"
else
error "Il n'y a pas de fichier Index.apxl"
end if -- parleAnglais()
else (*
Pages or Numbers *)
if my parleAnglais() then
error "Index.xml missing"
else
error "Il n'y a pas de fichier Index.xml"
end if -- parleAnglais()
end if -- typeID
end if -- exists file cheminXMLgz
end tell -- to System Events
return txtXML
end lis_Index
--=====
on expand(f)
do shell script "gunzip " & quoted form of (POSIX path of (f))
end expand
--=====
on lisIndex_xml(f)
local t
try
set t to ""
set t to (read file f)
end try
return t
end lisIndex_xml
--=====
on enregistre(leTexte, nDoc)
local aliasNDoc
set aliasNDoc to nDoc as alias
write leTexte to aliasNDoc starting at 0
(*
As it is a template we may gzip the index. *)
do shell script "gzip " & quoted form of POSIX path of (nDoc)

end enregistre
--=====
on expandFlat(f) (* f is an alias *)
local zipExt, qf, d, nn, nz, fz, qfz
set zipExt to ".zip"
set qf to quoted form of POSIX path of f
tell application "System Events"
tell disk item (f as text)
set d to path of container
set nn to name
set nz to nn & zipExt
set fz to d & nz
if exists disk item fz then set name of disk item fz to nn & my horoDateur(modification date of file fz) & zipExt
set name to nz
end tell -- disk item
make new folder at end of folder d with properties {name:nn}
end tell -- System Events

set qfz to quoted form of POSIX path of fz

do shell script "unzip " & qfz & " -d " & qf & " ; rm " & qfz
end expandFlat
--=====
on changeDoc2template(f) (* f is an alias *)
local qf, d, nn, oldExt, templExt, template_loc, myTemplate_loc, p2t
set qf to quoted form of POSIX path of f
tell application "System Events"
tell disk item (f as text)
set d to path of container
set nn to name
set oldExt to name extension
end tell -- disk item
end tell -- System Events

if typeID is in my permittedKey then (*
special case Keynote *)
set templExt to "kth"
else (*
Pages or Numbers *)
set templExt to "template"
end if -- typeID starts …
set nn to text 1 thru -(1 + (count of oldExt)) of nn & templExt
tell application "System Events" to set name of disk item (f as text) to nn (* now the doc is a template *)
set template_loc to getLocale(oldExt, "Templates")
set myTemplate_loc to getLocale(oldExt, "My Templates")
set p2t to ((path to application support from user domain) as text) & "iWork:" & oldExt & ":" & template_loc & ":" & myTemplate_loc & ":"
tell application "Finder" to move alias (d & nn) to folder p2t with replacing
end changeDoc2template
--=====
(*
• Build a stamp from the modification date_time
*)
on horoDateur(dt)
local annee, mois, jour, lHeure, lesSecondes, lesMinutes
set annee to year of dt
set mois to month of dt as number (* existe depuis 10.4 *)
set jour to day of dt
set lHeure to time of dt
set lesSecondes to lHeure mod 60
set lHeure to round (lHeure div 60)
set lesMinutes to lHeure mod 60
set lHeure to round (lHeure div 60)
return "_" & annee & text -2 thru -1 of ("00" & mois) & text -2 thru -1 of ("00" & jour) & "-" & text -2 thru -1 of ("00" & lHeure) & text -2 thru -1 of ("00" & lesMinutes) & text -2 thru -1 of ("00" & lesSecondes)
(*
• Here, the stamp is "_YYYYMMDD-hhmmss" *)
end horoDateur
--=====
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 getLocale(a, x)
tell application a to return localized string x
end getLocale
--=====
on parleAnglais()
local z
try
tell application "Pages" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]


Yvan KOENIG (from FRANCE jeudi 19 mars 2009 09:26:58)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Auto date and time in different languages

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.