🔖 dashboard v0.13.0 Globalization
				
					
				
			This commit is contained in:
		
							parent
							
								
									fe51b1afdc
								
							
						
					
					
						commit
						ade06839b7
					
				@ -4,7 +4,7 @@
 | 
				
			|||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
 | 
					  <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
 | 
				
			||||||
  <br><br>
 | 
					  <br><br>
 | 
				
			||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.30&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.9.0-brightgreen?style=for-the-badge&logo=linux">
 | 
					<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.13.0&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.9.1-brightgreen?style=for-the-badge&logo=linux"> <a title="Crowdin" target="_blank" href="https://crowdin.com/project/nezha"><img src="https://badges.crowdin.net/nezha/localized.svg"></a>
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <p>:trollface: <b>Nezha Monitoring</b> One-stop light monitoring and light operation and maintenance system. Supports system status, HTTP (SSL certificate change, upcoming expiration, expiration), TCP, Ping monitoring and alarm, scheduled tasks and web terminal.</p>
 | 
					  <p>:trollface: <b>Nezha Monitoring</b> One-stop light monitoring and light operation and maintenance system. Supports system status, HTTP (SSL certificate change, upcoming expiration, expiration), TCP, Ping monitoring and alarm, scheduled tasks and web terminal.</p>
 | 
				
			||||||
@ -14,7 +14,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
\>> QQ 交流群:872069346 **加群要求:已搭建好哪吒监控 & 有 2+ 服务器, 机器人自动审核**
 | 
					\>> QQ 交流群:872069346 **加群要求:已搭建好哪吒监控 & 有 2+ 服务器, 机器人自动审核**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\>> [Use Cases | 我们的用户](https://www.google.com/search?q="powered+by+哪吒监控"&filter=0) (Google)
 | 
					\>> [Use Cases | 我们的用户](https://www.google.com/search?q=%22powered+by+%E5%93%AA%E5%90%92%E7%9B%91%E6%8E%A7%22+OR+%22powered+by+Nezha+Monitoring%22&filter=0) (Google)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| Default Theme                                                                                 | DayNight [@JackieSung](https://github.com/JackieSung4ev)                                               | hotaru                                                                     |
 | 
					| Default Theme                                                                                 | DayNight [@JackieSung](https://github.com/JackieSung4ev)                                               | hotaru                                                                     |
 | 
				
			||||||
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
 | 
					| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
 | 
				
			||||||
 | 
				
			|||||||
@ -551,6 +551,7 @@ func (ma *memberAPI) logout(c *gin.Context) {
 | 
				
			|||||||
type settingForm struct {
 | 
					type settingForm struct {
 | 
				
			||||||
	Title                   string
 | 
						Title                   string
 | 
				
			||||||
	Admin                   string
 | 
						Admin                   string
 | 
				
			||||||
 | 
						Language                string
 | 
				
			||||||
	Theme                   string
 | 
						Theme                   string
 | 
				
			||||||
	CustomCode              string
 | 
						CustomCode              string
 | 
				
			||||||
	ViewPassword            string
 | 
						ViewPassword            string
 | 
				
			||||||
@ -572,6 +573,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
 | 
				
			|||||||
		})
 | 
							})
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						singleton.Conf.Language = sf.Language
 | 
				
			||||||
	singleton.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on"
 | 
						singleton.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on"
 | 
				
			||||||
	singleton.Conf.EnablePlainIPInNotification = sf.EnablePlainIPInNotification == "on"
 | 
						singleton.Conf.EnablePlainIPInNotification = sf.EnablePlainIPInNotification == "on"
 | 
				
			||||||
	singleton.Conf.Cover = sf.Cover
 | 
						singleton.Conf.Cover = sf.Cover
 | 
				
			||||||
@ -594,6 +596,8 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
 | 
				
			|||||||
		})
 | 
							})
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						// 更新系统语言
 | 
				
			||||||
 | 
						singleton.InitLocalizer()
 | 
				
			||||||
	c.JSON(http.StatusOK, model.Response{
 | 
						c.JSON(http.StatusOK, model.Response{
 | 
				
			||||||
		Code: http.StatusOK,
 | 
							Code: http.StatusOK,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
				
			|||||||
@ -108,7 +108,7 @@ func (oa *oauth2controller) callback(c *gin.Context) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	var isAdmin bool
 | 
						var isAdmin bool
 | 
				
			||||||
	for _, admin := range strings.Split(singleton.Conf.Oauth2.Admin, ",") {
 | 
						for _, admin := range strings.Split(singleton.Conf.Oauth2.Admin, ",") {
 | 
				
			||||||
		if admin != "" && gu.GetLogin() == admin {
 | 
							if admin != "" && strings.ToLower(gu.GetLogin()) == strings.ToLower(admin) {
 | 
				
			||||||
			isAdmin = true
 | 
								isAdmin = true
 | 
				
			||||||
			break
 | 
								break
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -68,3 +68,14 @@ func IPDesensitize(ipAddr string) string {
 | 
				
			|||||||
	ipAddr = ipv6Desensitize(ipAddr)
 | 
						ipAddr = ipv6Desensitize(ipAddr)
 | 
				
			||||||
	return ipAddr
 | 
						return ipAddr
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func PathExists(path string) (bool, error) {
 | 
				
			||||||
 | 
						_, err := os.Stat(path)
 | 
				
			||||||
 | 
						if err == nil {
 | 
				
			||||||
 | 
							return true, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if os.IsNotExist(err) {
 | 
				
			||||||
 | 
							return false, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								resource/template/common/menu.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								resource/template/common/menu.html
									
									
									
									
										vendored
									
									
								
							@ -1,9 +1,9 @@
 | 
				
			|||||||
{{define "common/menu"}}
 | 
					{{define "common/menu"}}
 | 
				
			||||||
<div class="ui large top fixed menu nb-menu">
 | 
					<div class="ui large top fixed menu nb-menu">
 | 
				
			||||||
    <div class="ui container">
 | 
					    <div class="ui container">
 | 
				
			||||||
        <div class="item">
 | 
					        <a class="item" href="/">
 | 
				
			||||||
            <img src="/static/logo.svg?v20210804">
 | 
					            <img src="/static/logo.svg?v20210804">
 | 
				
			||||||
        </div>
 | 
					        </a>
 | 
				
			||||||
        {{if .IsAdminPage}}
 | 
					        {{if .IsAdminPage}}
 | 
				
			||||||
        <a class='item{{if eq .MatchedPath "/server"}} active{{end}}' href="/server"><i class="server icon"></i>{{tr "Server"}}</a>
 | 
					        <a class='item{{if eq .MatchedPath "/server"}} active{{end}}' href="/server"><i class="server icon"></i>{{tr "Server"}}</a>
 | 
				
			||||||
        <a class='item{{if eq .MatchedPath "/monitor"}} active{{end}}' href="/monitor"><i class="rss icon"></i>{{tr "Services"}}</a>
 | 
					        <a class='item{{if eq .MatchedPath "/monitor"}} active{{end}}' href="/monitor"><i class="rss icon"></i>{{tr "Services"}}</a>
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,15 @@
 | 
				
			|||||||
                    <option value="mdui" {{if eq .Conf.Site.Theme "mdui" }} selected="selected" {{end}}>Neko Mdui</option>
 | 
					                    <option value="mdui" {{if eq .Conf.Site.Theme "mdui" }} selected="selected" {{end}}>Neko Mdui</option>
 | 
				
			||||||
                </select>
 | 
					                </select>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class="field">
 | 
				
			||||||
 | 
					                <label>Language</label>
 | 
				
			||||||
 | 
					                <select name="Language">
 | 
				
			||||||
 | 
					                    <option value="zh-CN" {{if eq .Conf.Language "zh-CN" }} selected="selected" {{end}}>
 | 
				
			||||||
 | 
					                        简体中文</option>
 | 
				
			||||||
 | 
					                    <option value="en-US" {{if eq .Conf.Language "en-US" }} selected="selected" {{end}}>
 | 
				
			||||||
 | 
					                        English</option>
 | 
				
			||||||
 | 
					                </select>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            <div class="field">
 | 
					            <div class="field">
 | 
				
			||||||
                <label>{{tr "CustomCodes"}}</label>
 | 
					                <label>{{tr "CustomCodes"}}</label>
 | 
				
			||||||
                <textarea name="CustomCode">{{.Conf.Site.CustomCode}}</textarea>
 | 
					                <textarea name="CustomCode">{{.Conf.Site.CustomCode}}</textarea>
 | 
				
			||||||
@ -86,6 +95,7 @@
 | 
				
			|||||||
                        time: '3',
 | 
					                        time: '3',
 | 
				
			||||||
                        position: 'top-center',
 | 
					                        position: 'top-center',
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					                    window.location.reload()
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    $.suiAlert({
 | 
					                    $.suiAlert({
 | 
				
			||||||
                        title: '',
 | 
					                        title: '',
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
debug: false
 | 
					debug: false
 | 
				
			||||||
httpport: 80
 | 
					httpport: 80
 | 
				
			||||||
 | 
					language: nz_language
 | 
				
			||||||
grpcport: nz_grpc_port
 | 
					grpcport: nz_grpc_port
 | 
				
			||||||
oauth2:
 | 
					oauth2:
 | 
				
			||||||
  type: "nz_oauth2_type" #Oauth2 登录接入类型,gitee/github
 | 
					  type: "nz_oauth2_type" #Oauth2 登录接入类型,gitee/github
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ NZ_BASE_PATH="/opt/nezha"
 | 
				
			|||||||
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
 | 
					NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
 | 
				
			||||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
 | 
					NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
 | 
				
			||||||
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
 | 
					NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
 | 
				
			||||||
NZ_VERSION="v0.9.0"
 | 
					NZ_VERSION="v0.9.1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
red='\033[0;31m'
 | 
					red='\033[0;31m'
 | 
				
			||||||
green='\033[0;32m'
 | 
					green='\033[0;32m'
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ NZ_BASE_PATH="/opt/nezha"
 | 
				
			|||||||
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
 | 
					NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
 | 
				
			||||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
 | 
					NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
 | 
				
			||||||
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
 | 
					NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
 | 
				
			||||||
NZ_VERSION="v0.9.0"
 | 
					NZ_VERSION="v0.9.1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
red='\033[0;31m'
 | 
					red='\033[0;31m'
 | 
				
			||||||
green='\033[0;32m'
 | 
					green='\033[0;32m'
 | 
				
			||||||
@ -290,10 +290,12 @@ modify_dashboard_config() {
 | 
				
			|||||||
    sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
					    sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
				
			||||||
    sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
					    sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
				
			||||||
    sed -i "s/nz_site_title/${nz_site_title}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
					    sed -i "s/nz_site_title/${nz_site_title}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
				
			||||||
 | 
					    sed -i "s/nz_language/en-US/" ${NZ_DASHBOARD_PATH}/data/config.yaml
 | 
				
			||||||
    sed -i "s/nz_site_port/${nz_site_port}/" ${NZ_DASHBOARD_PATH}/docker-compose.yaml
 | 
					    sed -i "s/nz_site_port/${nz_site_port}/" ${NZ_DASHBOARD_PATH}/docker-compose.yaml
 | 
				
			||||||
    sed -i "s/nz_grpc_port/${nz_grpc_port}/g" ${NZ_DASHBOARD_PATH}/docker-compose.yaml
 | 
					    sed -i "s/nz_grpc_port/${nz_grpc_port}/g" ${NZ_DASHBOARD_PATH}/docker-compose.yaml
 | 
				
			||||||
    sed -i "s/nz_image_url/${Docker_IMG}/" ${NZ_DASHBOARD_PATH}/docker-compose.yaml
 | 
					    sed -i "s/nz_image_url/${Docker_IMG}/" ${NZ_DASHBOARD_PATH}/docker-compose.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
 | 
					    echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    restart_and_update
 | 
					    restart_and_update
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,10 @@
 | 
				
			|||||||
package singleton
 | 
					package singleton
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"log"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/BurntSushi/toml"
 | 
						"github.com/BurntSushi/toml"
 | 
				
			||||||
 | 
						"github.com/naiba/nezha/pkg/utils"
 | 
				
			||||||
	"github.com/nicksnyder/go-i18n/v2/i18n"
 | 
						"github.com/nicksnyder/go-i18n/v2/i18n"
 | 
				
			||||||
	"golang.org/x/text/language"
 | 
						"golang.org/x/text/language"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@ -11,12 +14,20 @@ var Localizer *i18n.Localizer
 | 
				
			|||||||
func InitLocalizer() {
 | 
					func InitLocalizer() {
 | 
				
			||||||
	bundle := i18n.NewBundle(language.Chinese)
 | 
						bundle := i18n.NewBundle(language.Chinese)
 | 
				
			||||||
	bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
 | 
						bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
 | 
				
			||||||
	_, err := bundle.LoadMessageFile("resource/l10n/" + Conf.Language + ".toml")
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						userCustomLanguageFile := "resource/l10n/" + Conf.Language + ".toml"
 | 
				
			||||||
		panic(err)
 | 
					
 | 
				
			||||||
 | 
						if exists, err := utils.PathExists(userCustomLanguageFile); !exists {
 | 
				
			||||||
 | 
							log.Println("NEZHA>> language file not found:", userCustomLanguageFile, err)
 | 
				
			||||||
 | 
							Conf.Language = "zh-CN"
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							_, err := bundle.LoadMessageFile(userCustomLanguageFile)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								panic(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	_, err = bundle.LoadMessageFile("resource/l10n/zh-CN.toml")
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if _, err := bundle.LoadMessageFile("resource/l10n/zh-CN.toml"); err != nil {
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	Localizer = i18n.NewLocalizer(bundle, Conf.Language)
 | 
						Localizer = i18n.NewLocalizer(bundle, Conf.Language)
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ import (
 | 
				
			|||||||
	"github.com/naiba/nezha/pkg/utils"
 | 
						"github.com/naiba/nezha/pkg/utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Version = "v0.12.30" // !!记得修改 README 中的 badge 版本!!
 | 
					var Version = "v0.13.0" // !!记得修改 README 中的 badge 版本!!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	Conf  *model.Config
 | 
						Conf  *model.Config
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user