Different Languages

Silverstripe Version: 5

Question:

Hi,

My site has pages in 2 different languages.
How can I easily set lang TAG in each pages ?

The main page.ss set

<html lang="$ContentLocale">

How can I overwrite this for pages in other languages ?

The ContentLocale() method this gets its data from is defined in ContentController, which your page controllers should be subclasses of.

You can either override this method to have the relevant logic to return the correct locale per page, or else set the locale in the i18n class by calling i18n::set_locale(). You could call that method in the init() method of your page controller, for example.