Daily Lucky Numbers:
4
9
22
32
41
45

Any Chance for Language Switcher

Started by Ronald, September 24, 2022, 04:35:15 PM

Previous topic - Next topic

Ronald

Chen any chance you can whip up a code for changing the languages in a  portal block

Chen Zhen

#1
Create a top HTML type block with this content:
<div style="display: inline-flex;padding: 0rem;width: 100%;position: relative;overflow: hidden;align-items: right;justify-content: right;" id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
function insertMyGoogleTranslate() {
    var mySmfDiv = document.getElementById("google_translate_element");
    mySmfDiv.style.paddingRight = "0.3rem";
    mySmfDiv.style.paddingLeft = "0.3rem";
    mySmfDiv.style.lineHeight = "2rem";
    mySmfDiv.style.height = "2rem";
    mySmfDiv.style.overflowY = "hidden";
}
if (window.addEventListener)
    window.addEventListener("load", insertMyGoogleTranslate, false);
else
    window.attachEvent("onload", insertMyGoogleTranslate);
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Hide the title & body of the block.
(Style Options ->  checkboxes for: No Title + No Body)