<style>
    .ae-menubar #translate-panel {
        max-height: 360px;
        overflow: auto;
    }
    .ae-menubar .panel > .section .language-name.button {
        text-align: left ;
        justify-content: flex-start;
    }
    .ae-menubar .panel > .section .language-name.button a {
        padding: 0.875rem;
        width: 100%;
    }
    .ae-menubar .panel > .section .language-name.button {
        padding: 0;
    }
    .translate-subtitle {
        font-size: 10px;
    }
</style>
<div class="panel" id="translate-panel" role="dialog" aria-label="menu de contexto que permite a troca do tema da barra de menu" aria-hidden="true">
    <div class="section" id="themes">
        <input type="hidden" name="id_nmgp_idioma" id="id_nmgp_idioma" value="" />
        <ul id="languages-list">
            <?php
            $count_lang = 0;
            foreach ($this->Nm_lang_conf_region as $lang => $name) {
                $count_lang++;
                $active = '';
                $lang_temp = explode(';', $lang);
                if ($_SESSION['scriptcase']['str_lang'] == $lang_temp[0]) {
                    $active = 'active';
                }

                if (!empty($_SESSION['scriptcase']['charset']) && $_SESSION['scriptcase']['charset'] != 'UTF-8') {
//                    $name = mb_convert_encoding($name, $_SESSION['scriptcase']['charset'], 'UTF-8');
                    $name = json_encode($name, 2097152);
                    $name = substr($name, 1, -1);
                    $name = str_replace('\\/','/',  $name);
                    $name = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) {
                        return '&#x'.$match[1].';';
                    }, $name);
                }
                $name = preg_match('/^([\w]*[\/]?[^\-]*) - ([^\r\n]*)/',  $name, $matches_translate);
                ?>
                <li class="language-name button <?php echo $active; ?>">
                    <a href="javascript:changeLang('<?php echo $lang; ?>')" data-themeapply="data-themeapply" >
                        <strong><?php echo $matches_translate[1]; ?></strong>
                        <div class="translate-subtitle"><?php echo $matches_translate[2]; ?></div>
                    </a>
                </li>
                <?php
            }
            ?>
        </ul>
    </div>
</div>
<script>
    <?php
    if ($count_lang < 2) {
    ?>
    $(document).ready(function () {
        hideTBButton('translate');
    })
    <?php
    }
    ?>
    function Nm_change_lang_locale()
    {
        var str_location = window.location.toString();
        if (str_location.indexOf('script_case_init') == -1)
        {
            document.Nm_frm_change_lang_locale.hid_scr_iframe.value = str_location + (str_location.indexOf('?') > -1 ? '&' : '?');
        }
        else
        {
            document.Nm_frm_change_lang_locale.hid_scr_iframe.value = str_location;
        }
        document.Nm_frm_change_lang_locale.nmgp_idioma.value = document.getElementById("id_nmgp_idioma").value;
        document.Nm_frm_change_lang_locale.submit();
    }
    function changeLang(langVal) {
        $('#id_nmgp_idioma').val(langVal);
        Nm_change_lang_locale();
    }
</script>