Published on 05/1/2012

Multilingual presentations

  • Multilingual presentations

It is often useful to be able to change the language of a presentation on the fly, for example on a trade show. This article shows how to easily create with Tao Presentations a content that shows in different languages.




Changing language on the fly

Here is what the resulting presentation looks like. You can download it directly into Tao Presentations. You can change language by either pressing a key ("e" for English and "f" for French), or with a Language menu that the presentation created.


Creating a multilingual presentation easily

The code of the  presentation shown above demonstrates how easily you can create multilingual content:

// Main title slide
main_title_slide "Multilingual presentations" fr "Présentations multilingues"

// A simple text slide
slide "Creating multilingual slides" fr "Créer des présentations multilingues",
    * "Conditional text" fr "Texte conditionnel"
    - "The 'LANG' variable defines language" fr "La variable 'LANG' définit la langue"
    - "The 'language' function sets it" fr "La fonction 'language' la change"

    * "Keyboard shortcuts to switch languages" fr "Raccourcis claviers pour changer de langue"
    - "Use 'e' for English" fr "Tapez 'e' pour l'anglais"
    - "Use 'f' for French" fr "Tapez 'f' pour le français"

    * "Added a 'Language' menu entry" fr "Ajout d'un menu 'Langue'"
    - "Entries localized based on GUI language" fr "Affiché dans la langue de l'interface utilisateur"

    align 0.5
        translate 0, -100, 300
        rotatey 180 * sin time ^ 24
        color "white"
            image 0, 0, 100%, 100%, "English.gif"
            image 0, 0, 100%, 100%, "French.gif"

As you can see, there are two different ways to introduce localization. The first one is to use the "Texte Anglais" fr "Texte Français" notation. The second one is to bracket English parts with english and French parts with french.


Required definitions

The definitions required to make this multilingual presentation work are the following, placed in the file theme.xl (see how themes work):

// Switching languages
LANG -> "en"
Fr:text en En:text      -> if LANG = "en" then En else Fr
En:text fr Fr:text      -> if LANG = "fr" then Fr else En
french Body             -> if LANG = "fr" then Body 
english Body            -> if LANG = "en" then Body 
language L:text         -> LANG := L; refresh 0.1

The LANG variable specifies which language is currently in use. The notations with fr or en to separate two texts are simple conditional tests. Finally, french and english are simple shortcuts for conditional execuction of some code.

The following variant adds the possibility to start the presentation with the GUI language automatically:

LANG -> ""
lang -> if LANG = "" then tao_language else LANG
Fr:text en En:text      -> if lang = "en" then En else Fr
En:text fr Fr:text      -> if lang = "fr" then Fr else En
french Body             -> if lang = "fr" then Body 
english Body            -> if lang = "en" then Body 
language L:text         -> LANG := L; refresh 0.1

Keyboard activation

The following key definitions create two keyboard shortcuts with keys e and f two switch from one language to the other:

// Keyboard shortcuts
key "e" -> language "en"
key "f" -> language "fr"

Please note that when you change languages, a blank page may show up if the title of the page was itself translated. The reason is that Tao Presentations still shows the page with the old name, which no longer exists. Simply press a key, and Tao Presentations will show the translated page.


Changing languages with menu entries

The example presentation adds a "Language" menu to the user interface. This way, you can also change languages with a simple menu selection. Translation in that case is performed diffently, because we want the menu to show up in the language of the user interface, not the language currently selected for the presentation.

menu      "menu:language", tr "Language"
menu_item "menu:language > French", tr "French",
    language "fr"
menu_item "menu:language > English", tr "English",
    language "en"

// Translation of menu entries
if tr_lang <> tao_language and tao_language = "fr" then
    tr "Language", "Langue"
    tr "English", "Anglais"
    tr "French", "Français"

The first text given to menu ou menu_entry is a menu item identifier. The tr function is used to perform translations in the language chosen for the user interface.


Get closer to your audience

Speaking to your clients or your prospects in their native tongue is a good way to be closer to them. Creating multilingual presentations with Tao Presentations is so easy that it would be a shame not to do it!


No customer comments for the moment.

Add a comment