Basculer entre les langues dans Word / Switching between languages in Word

(the English version of this post is further down below)

J’écris souvent dans deux langues différentes (par exemple, dans ce blog :-> ). Dans Word, on peut basculer les réglages d’une sélection de texte d’une langue à une autre en fonction des besoins par Outils>Langues. C’est assez fastidieux (surtout quand on le fait souvent) et nécessite un nombre certain de clics. On peut utiliser différents modèles pour différentes langues, ou utiliser des styles particuliers pour différentes langues, mais je ne trouve pas cette approche très souple. J’utilisais donc jusque là des scripts en VBA, affectés à différents boutons sur une palette personnalisée pour basculer une sélection dans une langue ou dans l’autre.
Dans Word 2008, sorti la semaine dernière, plus de VBA, et plus de possibilité d’affecter des scripts à des boutons.
For heureusement il y a une solution de remplacement qui fonctionne très bien.
Paul Berkowitz m’a fait découvrir que l’on pouvait très facilement faire la même chose en AppleScript

Voilà par exemple pour modifier une sélection de texte et faire en sorte que Word sache qu’elle est en anglais (US) :

tell application “Microsoft Word”
     set language ID of selection to english us
end tell

On peut alors sélectionner le texte, lancer le script et voili 🙂
Pour les autres langues, il suffit de changer « english us » par le nom de la langue voulue (voir le bas de ce billet dans la section étendue).

script menuLe script peut alors être placé dans ~/Documents/Données Utilisateur Microsoft/Word Script Menu Items/ (~/ représente votre compte utilisateur — je ne suis pas 100% certain du fait que le nom du dernier dossier soit localisé ou pas avec la version française car je ne l’ai pas actuellement sur mon Mac)

Il est possible d’ajouter un suffixe au nom que l’on donne au script dans le Finder pour que l’on puisse le lancer d’un simple raccourcis clavier.
La syntaxe est la même que pour Entourage. English US\cU par exemple crée une crée une commande dans le menu Script de Word avec le raccourcis Ctrl-U

À titre d’exemple, le script pour le français et l’anglais (US) peuvent être téléchargés .
Vous pouvez en faire ce que vous voulez, les éditer pour utiliser une autre langue, etc…
Mille mercis à Paul pour l’information!


I often write in more than one language (eg: in this blog :-> ). In word, you can set the language for a selection of text to the language you need through Tools>Languages. I find this rather tedious (especially if you often have to do it) and requires quite a few clicks. You can use different templates for different languages, or different styles, but I don’t find this approach flexible enough. Until recently, I was using VBA scripts. They were assigned to a button on a custom toolbar and did the job quite well.
Word 2008 just came out, and the new version doesn’t support VBA anymore. You can’t bind a script to a button on a toolbar either.
I was discussing the issue with Paul Berkowitz lately and he suggested a wonderful alternate way to do the same thing through AppleScripts that works in Word 2008.

Here is how you can change the settings for a text selection so that Word knows it’s in French for instance:

tell application “Microsoft Word”
     set language ID of selection to french
end tell

All you have to do is to select the text, invoke the script and that’s it 🙂
For other languages, you just need to edit the script and replace ”french” with the appropriate name for the language you need (see below in the extended section for this post).

As illustrated in the capture above, the script can be placed in ~/Documents/Microsoft User Data/Word Script Menu Items/ (~/ represents your user account)

You can add a suffix, following the same syntax as in Entourage, to the name of the script in the Finder to provide a shortcut to invoke the script in Word. A name like French\cF for instance, provides the Ctrl-F shortcut to switch a selection in Word to French (see capture).

To make things easier, the scripts for French and English (US) can be downloaded here.
You can do whatever you want with them: edit them, use them for other languages, etc…

Many thanks to Paul for the tip!


Liste des langues supportées / list of supported languages:

language none
language no proofing
danish
german
swiss german
english aus
english uk
english us
english canadian
english new zealand
english south africa
spanish
french
french canadian
italian
dutch
norwegian bokmol
norwegian nynorsk
brazilian portuguese
portuguese
finnish
swedish
catalan
greek
turkish
russian
czech
hungarian
polish
slovenian
basque
malaysian
japanese
korean
simplified chinese
traditional chinese
swiss french
sesotho
tsonga
tswana
venda
xhosa
zulu
afrikaans
arabic
hebrew
slovak
farsi
romanian
croatian
ukrainian
byelorussian
estonian
latvian
macedonian
serbian latin
serbian cyrillic
icelandic
belgian french
belgian dutch
bulgarian
mexican spanish
spanish modern sort
swiss italian