

urls -> templates ?> images/logo-rund-80x80.png" alt="">

#Html css language switcher code#
In my sample I've used Boostrap 4 and the code below shows a complete navbar with our language switcher (BTW the language switcher will always be visible, even when the bootstrap navbar is collapsed): $languagecode = $language -> languagecode $url = $page -> localHttpUrl ( $language ) // Get the language code using custom languagecode field viewable ( $language )) // Get the http URL for this page in the given language
#Html css language switcher iso#
Now we are ready to write our template output!Īs we already have the appropriate two-letter ISO language code ( languagecode field), we can use this in our html lang property:Īlso the rel alternate output in the html head is simple. Title = English (in both language tabs! - this is important as your visitor should always see his language item. Title = Deutsch (in both language tabs! - this is important as your visitor should always see his language item. Name = default (this can't be changed and is read only) Now you can add the previously created field languagecode to the language template.Įdit your languages and fill in the appropriate values. To achieve this, go to Setup / Templates and activate the filter Show system templates : Here is an overview for ISO 639-1 two-letter language codes:Īdd this field to the system template: language. Without this field, you will need to programmatically construct your two-letter language code output via PHP (at least for the default language, as ProcessWire doesn't allow to rename the default language and it will always be called default). The field is needed to provide a simple method for outputting the language code in your templates. This will hold the ISO 639-1 two-letter language code for the respective language. In my case it's German (default language) + English: Setup at least 2 languages in your PW install.

TUTORIAL - Set up a nice language switcher for your website - here we go: There are some threads here in the forum (and from external sources) where this question is all others for your hints! I rewrote this tutorial since I was made aware and learned that flags should not be used for language selectors! I'm very new to ProcessWire but already fell in love with this CMS/CMF! I just finished my first small project and as I saw a lot of questions and different answers in this forum on how to set up a nice language switcher for your website, I decided to write my first tutorial.
