showIfLanguage

Task

The npspm instruction showIfLanguage makes it possible to show or hide parts of the content, depending on the language setting of the user:

Syntax

<npspm showIfLanguage="lang"> ... </npspm>

For lang one of the language codes consisting of two characters (such as de, en, fr, etc.) can be specified.

How the user's language is determined depends on the configuration. If no single language has been associated to the host, the language will be determined either by means of the user's browser settings, an optional attribute of the logged-in user, or the lang request parameter. The behaviour can be configured via the LanguageFilter in the file WEB-INF/web.xml.

Example

<npspm showIfLanguage="de">Deutscher Inhalt</npspm>
<npspm showIfLanguage="de" negate="true">English content</npspm>

For German-language users "Deutscher Inhalt" is displayed while "English content" is displayed for all other users.