Forcing a change in the interface language

As a final note of importance regarding multilingualism, some people may want to have a mix of languages between the interface and the content, yet still wish to maintain some consistency. More specifically, many would like to display the articles in the source languages if they have not as yet been translated into the requested language. In such cases, you will need to activate the forcer_lang setting.

Nonetheless, when displaying an article, it is possible to list the other various existing translations, as is done in the SPIP model code modeles/articles_traductions.html, where the generated link does not change the interface language, given that forcer_lang maintains the visitor’s language.

If you would prefer that clicking on a translation link implies changing the interface language as well (into the same language as that of the translated article), then you will need to edit the model code for articles_traductions.html or create a new version. We then use the "converser" action enabling the generation of a special link which redirects to the desired article in the desired interface language:

  1. [(#VAL{converser}
  2. |generer_url_action{[redirect=(#URL_ARTICLE
  3. |parametre_url{var_lang,#LANG})]})]


Example of a complete (and complex!) model:

This is a model that lists the various translations of an article. If it is not the translation currently being viewed, a link is proposed indicating the translation language.

  1. <BOUCLE_article(ARTICLES){id_article}>
  2. <BOUCLE_traductions(ARTICLES) {traduction} {par lang} {','}>[
  3. (#TOTAL_BOUCLE|>{1}|?{' '})
  4. <span lang="#LANG" xml:lang="#LANG" dir="#LANG_DIR"[ class="(#EXPOSE)"]>
  5. [(#EXPOSE{'',<a href="[(#VAL{converser}
  6. |generer_url_action{[redirect=(#URL_ARTICLE
  7. |parametre_url{var_lang,#LANG})]})]" rel="alternate" hreflang="#LANG"[ title="(#TITRE|attribut_html|couper{80})"]>})]
  8. [(#LANG|traduire_nom_langue)]
  9. #EXPOSE{'',</a>}
  10. </span>
  11. ]</BOUCLE_traductions>
  12. </BOUCLE_article>


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

Translations : English, français