mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
进一步的网页国际化支持
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
{
|
||||
"username": "用户名: ",
|
||||
"password": "密码: ",
|
||||
"2fa_code": "2FA 验证码: ",
|
||||
"2fa_code": "2FA 验证: ",
|
||||
"if_enabled": "如果有",
|
||||
"login": "登录",
|
||||
"select_language": "选择语言: ",
|
||||
"chinese": "简体中文",
|
||||
"english": "英语"
|
||||
"english": "英语",
|
||||
"footer-left": "本网站需要使用 JavaScript 功能。<br>本网站不含广告,但仍有可能会被某些广告过滤器屏蔽。<br>如果网页响应异常请关闭它并重新加载页面以继续浏览。",
|
||||
"index": " One-KVM 导航 ",
|
||||
"copyright": "版权所有 © 2018-2024 Maxim Devaev | 由 SilentWind 二次开发",
|
||||
"index_text_1": "请注意,在使用 KVM 会话或其他可捕获键盘的应用程序时,您无法使用某些快捷键,如 Ctrl+Alt+Del(这会被操作系统捕获)或 Ctrl+W(这会被浏览器捕获)。",
|
||||
"index_text_2": "要突破这一限制,您可以在应用程序模式下使用 Google Chrome 浏览器。",
|
||||
"serve_name": "主机名:",
|
||||
"index_text_10":"PiKVM 项目",
|
||||
"index_text_11":"PiKVM 文档",
|
||||
"index_text_12":"One-KVM 项目",
|
||||
"index_text_13":"One-KVM 文档",
|
||||
"index_title":"开源 KVM over IP"
|
||||
}
|
||||
@@ -6,5 +6,16 @@
|
||||
"login": "Login",
|
||||
"select_language": "Select language: ",
|
||||
"chinese": "Simplified Chinese",
|
||||
"english": "English"
|
||||
"english": "English",
|
||||
"footer-left": "This site is actively using JavaScript.<br>It doesn't contain ads, but is blocked by some ad filters.<br>Please turn it off to continue and reload the page.",
|
||||
"index": " One-KVM Index ",
|
||||
"copyright": "Copyright © 2018-2024 Maxim Devaev | Modified by SilentWind",
|
||||
"index_text_1": "Please note that when you are working with a KVM session or another application that captures the keyboard,you can't use some keyboard shortcuts such as Ctrl+Alt+Del (which will be caught by your OS) or Ctrl+W (caught by your browser).",
|
||||
"index_text_2": "To override this limitation you can use Google Chrome in application mode.",
|
||||
"serve_name": "Server:",
|
||||
"index_text_10":"PiKVM Project",
|
||||
"index_text_11":"PiKVM Documentation",
|
||||
"index_text_12":"One-KVM Project",
|
||||
"index_text_13":"One-KVM Documentation",
|
||||
"index_title":"The Open Source KVM over IP"
|
||||
}
|
||||
@@ -1,14 +1,50 @@
|
||||
/* cookie存储用户选取的值 */
|
||||
function setCookie (name, value)
|
||||
{
|
||||
/* 设置名称为name,值为value的Cookie */
|
||||
var expdate = new Date();
|
||||
/* 计算时间,30天后过期 */
|
||||
expdate.setTime(expdate.getTime() + 30 * 24 * 60 * 60 * 1000);
|
||||
document.cookie = name + "=" + value + "; expires=" + expdate.toGMTString() + "; path=/" + ";SameSite=Lax";
|
||||
/* 即document.cookie= name+"="+value+";path=/"; 时间可以不要,但路径(path)必须要填写,因为JS的默认路径是当前页,如果不填,此cookie只在当前页面生效! */
|
||||
}
|
||||
|
||||
/* 获取cookie */
|
||||
function getCookie(name)
|
||||
{
|
||||
if (document.cookie.length > 0)
|
||||
{
|
||||
start = document.cookie.indexOf(name + "=")
|
||||
if (start != -1)
|
||||
{
|
||||
start = start + name.length + 1
|
||||
end = document.cookie.indexOf(";", start)
|
||||
if (end == -1) end = document.cookie.length
|
||||
return unescape(document.cookie.substring(start, end))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置语言类型: 默认为中文
|
||||
*/
|
||||
var i18nLanguage = "cn";
|
||||
|
||||
$(document).ready(function() {
|
||||
/*默认语言*/
|
||||
var defaultLang = "cn";
|
||||
/* 首先获取用户选择过的语言 */
|
||||
if (getCookie('userLanguage')) {
|
||||
i18nLanguage = getCookie('userLanguage');
|
||||
}
|
||||
|
||||
$("[i18n]").i18n({
|
||||
defaultLang: defaultLang,
|
||||
defaultLang: i18nLanguage,
|
||||
filePath: "/share/i18n/",
|
||||
filePrefix: "i18n_",
|
||||
fileSuffix: "",
|
||||
forever: true,
|
||||
callback: function() {
|
||||
console.log("i18n is ready.");
|
||||
|
||||
}
|
||||
});
|
||||
/*切换为中文 - 按钮*/
|
||||
@@ -17,6 +53,7 @@ $(document).ready(function() {
|
||||
defaultLang: "cn",
|
||||
filePath: "/share/i18n/"
|
||||
});
|
||||
setCookie('userLanguage', "cn")
|
||||
});
|
||||
/*切换为英文 - 按钮*/
|
||||
$(".english").click(function() {
|
||||
@@ -24,6 +61,7 @@ $(document).ready(function() {
|
||||
defaultLang: "en",
|
||||
filePath: "/share/i18n/"
|
||||
});
|
||||
setCookie('userLanguage', "en")
|
||||
});
|
||||
|
||||
});
|
||||
@@ -32,23 +32,10 @@ export function main() {
|
||||
initWindowManager();
|
||||
|
||||
if (checkBrowser(null, null)) {
|
||||
__setAppText();
|
||||
__loadKvmdInfo();
|
||||
}
|
||||
}
|
||||
|
||||
function __setAppText() {
|
||||
$("app-text").innerHTML = `
|
||||
<span class="code-comment"># On Linux using Chromium/Chrome via any terminal:<br>
|
||||
$</span> \`which chromium 2>/dev/null || which chrome 2>/dev/null || which google-chrome\` --app="${window.location.href}"<br>
|
||||
<br>
|
||||
<span class="code-comment"># On MacOS using Terminal application:<br>
|
||||
$</span> /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app="${window.location.href}"<br>
|
||||
<br>
|
||||
<span class="code-comment"># On Windows via cmd.exe:<br>
|
||||
C:\></span> start chrome --app="${window.location.href}"
|
||||
`;
|
||||
}
|
||||
|
||||
function __loadKvmdInfo() {
|
||||
tools.httpGet("/api/info?fields=auth,meta,extras", function(http) {
|
||||
|
||||
Reference in New Issue
Block a user