是否可以使语言自动切换到访问者?

时间:2017-04-18 20:50:08

标签: javascript php html

您好,我试图让我的网站根据访问者的语言更改语言,我目前正在为网站添加两种语言。这是我使用它的代码

$(document).ready(function() {
    $("#lang").on('change', function() {
        $( "#lang_form" ).submit();
    });
});
</script>

{/if}
    {if $setting_show_language_picker}
    <div class="row lang-picker">
        <div class="col-sm-2 col-sm-offset-5">
            <form id="lang_form" class="form" action="" method="POST">
                <input type="hidden" name="callback" value="{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" />
                <select id="lang" class="form-control input-sm" name="lang">
                    {foreach $all_langs as $language}
                        <option value="{$language}"{if $curr_lang == $language} selected{/if}>{$language|capitalize}</option>
                    {/foreach}
                </select>
            </form>
        </div>
    </div>
    {/if}
</div>
{if $pid == 7 || $pid == 8}
    <script type="text/javascript" charset="utf-8">
        $(document).ready(function() {
            $('#links_table,#campaigns_table').dataTable({
                language: {
                    search: "{$lang_105}",
                    paginate: {
                        first:      "{$lang_106}",
                        previous:   "{$lang_107}",
                        next:       "{$lang_108}",
                        last:       "{$lang_109}"
                    },
                    emptyTable: "{$lang_94}",
                    info: "{$lang_110}",
                    lengthMenu: "{$lang_111}"
                }
            } );
        });

0 个答案:

没有答案