-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问大佬 merger.justhx.com 的多语言自动识别是通过什么实现的? #9
Comments
merger.justhx.com 本身没有做多语言识别,但是 https://docs.justhx.com/merger 是通过如下代码实现的: var userLang = navigator.language || navigator.userLanguage;
if (userLang.includes("zh") || userLang.includes("cn")) {
window.location.replace("https://merger.justhx.com/cn/");
}
else {
window.location.replace("https://merger.justhx.com/");
} 在写这类型代码的时候,请注意永远有一个 else { } fallback,即就算判断条件一个都不符合,也要给访客一个目的地。 |
才发现只有测试版才支持多语言。。。对了,大佬加上下面的代码,让 PayPal 的弹窗居中出现吧?正式版屏幕左上角出现就很怪异。我的Merger用的是默认的CDN,所以我在本地改没效果,您可以在这里看效果,第一行的卡片的右边就是贝宝。 function openbox() {
var paypal = "https://www.paypal.me/andrewsun74";
//window.screen.height获得屏幕的高,window.screen.width获得屏幕的宽
var iWidth = 500; //弹出窗口的宽度;
var iHeight = 640; //弹出窗口的高度;
var iTop = (window.screen.height-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.width-10-iWidth)/2; //获得窗口的水平位置;
selected = "yes";
window.open(
paypal,
"_blank",
'height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no'
)
} |
@littlegolden 这是一个好建议,将在下一个版本补充;但是我记得不需要这么繁复的 js...你可以去看看 function.js 里面应该是有的。 同时,目前 0.20 版本为 pre-release - 预先发布,而非测试版。0.20 版本仅有一个小错误,将会在下一个版本修复。 目前 0.20 还是预发布版本的原因为英文文档还没有同步新功能。 |
已于 084a93a 添加此特性;稍后会合并到主分支并发布新版本。 |
用 Accept-Language 吗?是用下面的方法吗?在主页用下面的js,会导致非中文用户无法自行跳转到中文页面。
The text was updated successfully, but these errors were encountered: