找回密码
 立即注册
即日起,论坛关闭新用户注册和登录,论坛相关的贴子保留查阅和下载。获得授权后,有技术问题可联系微信 13199509559 一对一解决。 2024-3-12
查看: 823|回复: 0
打印 上一主题 下一主题

ourphp多语言网站根据不同语言的系统跳转对应语言网站页面

209

主题

209

主题

209

主题

管理员

Rank: 9Rank: 9Rank: 9

积分
0
跳转到指定楼层
1#
 楼主| admin 发表于 2023-11-12 20:56:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

ourphp多语言网站根据不同语言的系统跳转对应语言网站页面

一、先学会创建多语言网站
学习链接:
https://www.ourphp.net/club/forum.php?mod=viewthread&tid=19


二、在模板中插入多语言点击跳转标签
演示:http://l.ourphp.net/
用户根据页面上的提示,点击对应语言网页的链接。

需要在模板中插入调用多语言模块的标签代码:
请在这里选择网站语言:【
[.sql mysql="select * from ourphp_lang order by id asc" font="未找到数据!" name="sql".]
<a href="?[.$sql.OP_Lang.]-index.html" >[.$sql.OP_Font.]</a> -
[./sql.]





三、根据用户的手机或电脑系统语言自动跳转到指定语言的网页上
首先,用IP来判断用户所在区域,在跳转对应的语言网页上有点不太现实。  全球IP库这么大,判断需要的时间太长。
那唯一能解决的方案就是判断用户使用的系统或浏览器语言。如 美国用户用的是英文系统或浏览器。根据浏览器标识来判断。

PC端请在   /index.php 中 include './function/ourphp_template.class.php'; 后面插入如下代码:
$gourl = $ourphp['webpath'];
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$acceptLang = ['zh', 'fr', 'it', 'en'];
$lang = in_array($lang, $acceptLang) ? $lang : 'cn';
if($temptype != $lang)
{
        if($lang == "zh")
        {
                $lang = 'cn';
        }
        echo '
                <script>
                           window.location.href = "'.$gourl.'?'.$lang.'-index.html";
                </script>        
        ';
        exit(0);
}

其中$acceptLang = ['zh', 'fr', 'it', 'en']; 是预先设置语种数组,要和你ourphp后台 -》全局-》网站语言配置中要一样。
zh 是简体中文。

手机移动端
在 /client/wap/index.php 中 include './function/ourphp_template.class.php'; 后面插入代码
把 $gourl = $ourphp['webpath']; 改成  $gourl = $ourphp['webpath'].'client/wap/';

即可





您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表