How To Implement Google Translate Into A CMS Website

A few days ago, I got a project from my client. A project CMS Website which is has to feature multilanguage. Long story short when I developed this module. I’m having problems. Namely how to hide Google translate elements that are on top of the page. Alhamdulillah, thank God, finally I found his enlightenment through this blog and some discussions on Stackoverflow.

As a thank you for successfully completing this project. I will share a simple way how to implement the google translate feature into the CMS Website.

You can create a new file named style.css

    margin: 0 auto;
    padding: 0px 10px;
    top: 0px !important;

    margin: 0px;
    padding: 0px;
ul.translation-icons li.translate{
    display: inline-block;
    padding: 5px 10px;

.goog-te-gadget-icon {
.goog-te-gadget-simple a {
    text-decoration: none !important;
.goog-te-banner-frame.skiptranslate {
    display: none !important;

    display: none !important;
    display: none;

You can create a new file named index.html

<!DOCTYPE html>
    <title>.: Google Translate Integration :.</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    <link rel="stylesheet" type="text/css" href="style.css">
    <ul class="translation-icons">
        <li class="translate">
            <a href="#googtrans(en|id)" class="indonesian" data-lang="Indonesian">
                <img src="in.gif"/>&nbsp;IND
        <li class="translate">
            <a href="#googtrans(id|en)" class="english" data-lang="English">
                <img src="en.gif"/>&nbsp;EN

    <p>Halo Dunia, Saya mau memperkenalkan diri. Nama saya Bramanto.</p>
    <div id="google_translate_element"></div>
    <script src="" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
    <script type="text/javascript">
        function googleTranslateElementInit() {
              new google.translate.TranslateElement({
                pageLanguage: 'en', 
                includedLanguages: 'en,id',
                defaultLanguage: 'en',
                multilanguagePage: true,
                layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
                autoDisplay: false
            }, 'google_translate_element');

        (function() {
          var googleTranslateScript = document.createElement('script');
          googleTranslateScript.type = 'text/javascript';
          googleTranslateScript.async = true;
          googleTranslateScript.src = '//';
          ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( googleTranslateScript );

        $(document).on("click", "ul.translation-icons li.translate a",function() {
            var lang = $(this).data('lang');
            var $frame = $('.goog-te-menu-frame:first');
            if (!$frame.length) {
                alert("Error: Could not find Google translate frame.");
                return false;
            $('.goog-te-menu-frame:first').contents().find('.goog-te-menu2-item span.text').each(function(){
                if($(this).html() == lang){
            return false;

        $(document).on("touchstart", "ul.translation-icons li.translate a",function() {
            var theLang = jQuery(this).attr('data-lang');

            window.location = jQuery(this).attr('href');

By the way, don’t forget to turn on your internet connection to try this feature.

Content in Indonesian
Content in English

If you have another code reference and of course it has run perfectly. Please comment on this post. I am also always open to criticism and suggestions and discussions related to technology.

Thank you for reading this post.