Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

增加自动根据浏览器语言显示对应语言的页面 #9

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

Closed
Aurorum-Studio wants to merge 2 commits into xiangyuecn:main from Aurorum-Studio:main

Conversation

Copy link

@Aurorum-Studio Aurorum-Studio commented Aug 2, 2024

在标签中增加一个函数实现根据浏览器的语言设置自动选择中文/英文版本的页面。
Adding the ability to automatically choose the language displayed on the page according to the language setting of the user's browser.

Copy link
Owner

查阅了一下你提交的这段代码,除了给body添加一个langZH/langEN的class之外,并没有做任何事情,也无任何实际效果,属于无效代码。

现有代码支持自动根据浏览器语言来显示的功能,并且支持手动切换语言:

window.LangCur=/\b(zh|cn)\b/i.test(navigator.language)?"cn":"en";
window.Lang=function(cn,en,txt){
if((cn||en) && (!cn||!en))throw new Error("Lang bad args");
if(txt)return LangCur=="cn"?cn:en;
var html="",ks={cn:cn,en:en};
LangClick(LangCur);
initMainUI();
})();
</script>
<!-- PageRawHTML: 后面不许放内容 -->

Copy link
Author

我刚才用edge重新测试了下,您原本的代码是能够实现自动切换语言,我平时常用火狐,可能是火狐的缓存机制影响了这个功能的实现吧😅,这样的话我的代码确实多余了,我就结题了吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /