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:


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.

<BOUCLE_traductions(ARTICLES) {traduction} {par lang} {','}>[
	(#TOTAL_BOUCLE|>{1}|?{' '})
	<span lang="#LANG" xml:lang="#LANG" dir="#LANG_DIR"[ class="(#EXPOSE)"]>
		[(#EXPOSE{'',<a href="[(#VAL{converser}
				|parametre_url{var_lang,#LANG})]})]" rel="alternate" hreflang="#LANG"[ title="(#TITRE|attribut_html|couper{80})"]>})]

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français, Nederlands