Koha Test Wiki MW Canasta on Koha Portainer

Test major Koha Wiki changes or bug fixes here without fear of breaking the production wiki.

For the current Koha Wiki, visit https://wiki.koha-community.org .

Switching languages for HTML system preferences

From Koha Test Wiki MW Canasta on Koha Portainer
Jump to navigation Jump to search

A number of Koha system preferences can take HTML content, like e.g. OpacMainUserBlock. But what can you do if you need your content in different languages? Here is a trick (the examples assume you want to be able to switch between German (de-DE) and English (en)):

Put this in your OpacUserJS system preference:

if ($('html').attr('lang')=='de-DE') {
  $(".de-DE").show();
  $(".en").hide();
} else {
  $(".de-DE").hide();
  $(".en").show();
}

Then you can put content like this in the system preferences that take HTML and where you want different languages to appear, based on the choice of the user:

<div class="en">
...
</div>
<div class = "de-DE">
...
</div>

(Based on an email from Katrin Fischer to the main Koha list.)