Special language criteria

Some special loop criteria make it possible to retrieve articles in a specifically desired language.

lang

First of all, the quite simple {lang} criterion enables us to select the visitor’s language or a specific language:

  1. // language of the visitor
  2. <BOUCLE_art(ARTICLES){lang}> ... </BOUCLE_art>
  3. // English language (en)
  4. <BOUCLE_art(ARTICLES){lang=en}> ... </BOUCLE_art>

Download

traduction

The {traduction} criterion enables us to list the various translations of an article:

  1. <BOUCLE_article(ARTICLES){id_article}>
  2. <ul>
  3. <BOUCLE_traductions(ARTICLES) {traduction}{par lang}>
  4. <li>[(#LANG|traduire_nom_langue)]</li>
  5. </BOUCLE_traductions>
  6. </ul>
  7. </BOUCLE_article>

Download

In this case, all the translations of an article will be displayed (including the current article, which could be excluded by specifically adding the {exclus} criterion).

origine_traduction

This criterion enables us to retrieve the original source article for a particular translated article, that being the one that serves as the source reference to the other translations. To show all of the source articles, use:

  1. <BOUCLE_sources(ARTICLES) {origine_traduction}>
  2. #TITRE (#LANG)<br />
  3. </BOUCLE_sources>

Download

To show the original translation for an article (the one in the current context):

  1. <BOUCLE_article(ARTICLES){id_article}>
  2. <BOUCLE_origine(ARTICLES) {traduction}{origine_traduction}>
  3. #TITRE (#LANG)
  4. </BOUCLE_origine>
  5. </BOUCLE_article>

Download

Example

Display an article in the visitor’s language where possible, and if not, then in the main language.

We start by listing, for a section, all the articles which serve as sources for the creation of translations. We then continue by checking if a translation exists in the language requested by the visitor. Depending on the result, we display the title of the translated article or that of the source article.

  1. <BOUCLE_art1(ARTICLES){id_rubrique}{origine_traduction}>
  2. <BOUCLE_art2(ARTICLES){traduction}{lang=#ENV{lang}}>
  3. // if a translation does exist
  4. <li>#TITRE</li>
  5. </BOUCLE_art2>
  6. // otherwise use the original article's title
  7. <li>#TITRE</li>
  8. <//B_art2>
  9. </BOUCLE_art1>

Download

Author Mark Baber Published : Updated : 27/06/10

Translations : English, français