Skip to content
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

Web server i18n #11

Merged
merged 7 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/i18n/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,62 @@ func en() {
return message
}
UnknownCommand = "Unknown command"

WebConfig = "Web Config"
EnableWebServer = "Enable Web Server"
EnableWebServerDisablePrompt = "Do you want to disable web server? You need to modify .env file to enable it again."
WebServerPort = "Web Server Port"
WebServerPortTooltip = "Set the port of web server. It is recommended to use a number above 60000."

Language = "Language"
SelectLanguage = "Select Language"

DiscordBotConfig = "Discord Bot Config"
EnableDiscordBot = "Enable Discord Bot"
DiscordBotToken = "Discord Bot Token"
DiscordBotTokenTooltip = "Enter the token of the Discord bot. You can find out how to get the token by clicking the ? button you are currently hovering over."
DiscordAdminUsernames = "Discord Admin Usernames"
DiscordAdminUsernamesTooltip = "Enter the nicknames of Discord admins. If there are multiple, separate them with a comma."
DiscordCommandCaseSensitive = "Discord Command Case Sensitive"
DiscordCommandCaseSensitiveTooltip = "Set whether to distinguish the case of Discord commands."
DiscordCommandPrefix = "Discord Bot Call Command"
DiscordCommandPrefixTooltip = "Set the command to call the Discord bot."

PalworldConfig = "Palworld Config"
EnablePalworldRcon = "Enable Palworld RCON (Please set RCONEnable value in PalWorldSettings.ini to true in advance.)"
PalworldRconHost = "Palworld RCON Host"
PalworldRconHostTooltip = "Enter the address of the server where the Palworld server is running."
PalworldRconPort = "Palworld RCON Port"
PalworldRconPortTooltip = "Enter the port of the server where the Palworld server is running."
PalworldAdminPassword = "Palworld Admin Password"
PalworldAdminPasswordTooltip = "Enter the password of the Palworld server."
PalworldServerFilePath = "Palworld Server File Path"
PalworldServerFilePathTooltip = "Enter the path of the Palworld server file."
PalworldServerExecuteFlags = "Palworld Server Execute Flags"
PalworldServerExecuteFlagsTooltip = "Enter the flags of the Palworld server."

DiscordChannelConfig = "Discord Channel Config"
DiscordDashboardChannelID = "Discord Dashboard Channel ID"
DiscordDashboardChannelIDTooltip = "Enter the channel ID for using the dashboard function. If not entered, the function is not used. You can find out how to check the channel ID by clicking the ? button you are currently hovering over."
DiscordLogChannelID = "Discord Log Channel ID"
DiscordLogChannelIDTooltip = "Enter the channel ID to check the user's connection/disconnection record. If not entered, the function is not used. You can find out how to check the channel ID by clicking the ? button you are currently hovering over."
DiscordDashboardOnlinePlayersMessageID = "Discord Dashboard Online Players Message ID"
DiscordDashboardOnlinePlayersMessageIDTooltip = "Automatically set value. If not necessary, do not modify."
DiscordDashboardPalworldConfigMessageID = "Discord Dashboard Palworld Config Message ID"
DiscordDashboardPalworldConfigMessageIDTooltip = "Automatically set value. If not necessary, do not modify."
DiscordDashboardBotConfigMessageID = "Discord Dashboard Bot Config Message ID"
DiscordDashboardBotConfigMessageIDTooltip = "Automatically set value. If not necessary, do not modify."

DiscordCommandAliases = "Discord Command Aliases"
DiscordCommandAliasKickTooltip = "Kick command customizing"
DiscordCommandAliasBanTooltip = "Ban command customizing"
DiscordCommandAliasBroadcastTooltip = "Broadcast all users command customizing"
DiscordCommandAliasShutdownTooltip = "Shutdown after few seconds command customizing"
DiscordCommandAliasDoExitTooltip = "Server force shutdown command customizing"
DiscordCommandAliasSaveTooltip = "Save command customizing"
DiscordCommandAliasStartServerTooltip = "StartServer command customizing"

Close = "Close"
Confirm = "Confirm"
Save = "Save"
}
94 changes: 78 additions & 16 deletions src/i18n/i18n.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package i18n

var Languages = []map[string]string{
{"CODE": "ko", "NAME": "한국어"},
{"CODE": "en", "NAME": "English"},
{"code": "ko", "name": "한국어"},
{"code": "en", "name": "English"},
}

func SetLanguage(language string) {
Expand All @@ -15,17 +15,79 @@ func SetLanguage(language string) {
}
}

var BotRunningStart string
var FailedToConnectRconServer string
var FailedToSaveCommand string
var FailedToDoExitCommand string
var FailedToShutdownCommand string
var FailedToBroadcastCommand string
var FailedToKickCommand string
var FailedToBanCommand string
var FailedToShowPlayerCommand string
var FailedToStartServerCommand string
var SuccessToStartServerCommand string
var WrongParameters string
var Help func(commandPrefix string, isAdmin bool) string
var UnknownCommand string
var (
BotRunningStart string
FailedToConnectRconServer string
FailedToSaveCommand string
FailedToDoExitCommand string
FailedToShutdownCommand string
FailedToBroadcastCommand string
FailedToKickCommand string
FailedToBanCommand string
FailedToShowPlayerCommand string
FailedToStartServerCommand string
SuccessToStartServerCommand string
WrongParameters string
UnknownCommand string
Help func(commandPrefix string, isAdmin bool) string
)

var (
WebConfig string
EnableWebServer string
EnableWebServerDisablePrompt string
WebServerPort string
WebServerPortTooltip string

Language string
SelectLanguage string

DiscordBotConfig string
EnableDiscordBot string
DiscordBotToken string
DiscordBotTokenTooltip string
DiscordAdminUsernames string
DiscordAdminUsernamesTooltip string
DiscordCommandCaseSensitive string
DiscordCommandCaseSensitiveTooltip string
DiscordCommandPrefix string
DiscordCommandPrefixTooltip string

PalworldConfig string
EnablePalworldRcon string
PalworldRconHost string
PalworldRconHostTooltip string
PalworldRconPort string
PalworldRconPortTooltip string
PalworldAdminPassword string
PalworldAdminPasswordTooltip string
PalworldServerFilePath string
PalworldServerFilePathTooltip string
PalworldServerExecuteFlags string
PalworldServerExecuteFlagsTooltip string

DiscordChannelConfig string
DiscordDashboardChannelID string
DiscordDashboardChannelIDTooltip string
DiscordLogChannelID string
DiscordLogChannelIDTooltip string
DiscordDashboardOnlinePlayersMessageID string
DiscordDashboardOnlinePlayersMessageIDTooltip string
DiscordDashboardPalworldConfigMessageID string
DiscordDashboardPalworldConfigMessageIDTooltip string
DiscordDashboardBotConfigMessageID string
DiscordDashboardBotConfigMessageIDTooltip string

DiscordCommandAliases string
DiscordCommandAliasKickTooltip string
DiscordCommandAliasBanTooltip string
DiscordCommandAliasBroadcastTooltip string
DiscordCommandAliasShutdownTooltip string
DiscordCommandAliasDoExitTooltip string
DiscordCommandAliasSaveTooltip string
DiscordCommandAliasStartServerTooltip string

Close string
Confirm string
Save string
)
58 changes: 58 additions & 0 deletions src/i18n/ko.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,62 @@ func ko() {
return message
}
UnknownCommand = "알 수 없는 명령어입니다."

WebConfig = "웹 설정"
EnableWebServer = "웹 서버 사용"
EnableWebServerDisablePrompt = "웹 서버를 사용하지 않으시겠습니까? 이후 다시 설정하시려면 .env 파일을 수정하셔야 합니다."
WebServerPort = "웹 서버 포트"
WebServerPortTooltip = "웹 서버의 포트를 설정합니다. 되도록 60000 이상의 숫자를 사용하시길 권장합니다."

Language = "언어"
SelectLanguage = "언어 선택"

DiscordBotConfig = "디스코드 봇 설정"
EnableDiscordBot = "디스코드 봇 사용"
DiscordBotToken = "디스코드 봇 토큰"
DiscordBotTokenTooltip = "디스코드 봇의 토큰을 입력하세요. 토큰을 얻는 방법은 현재 마우스를 올리고 있는 ? 버튼을 클릭하시면 확인하실 수 있습니다."
DiscordAdminUsernames = "디스코드 관리자 닉네임"
DiscordAdminUsernamesTooltip = "디스코드 관리자의 닉네임을 입력하세요. 여러명일 경우 쉼표로 구분합니다."
DiscordCommandCaseSensitive = "디스코드 커맨드 대소문자 구분"
DiscordCommandCaseSensitiveTooltip = "디스코드 커맨드의 대소문자를 구분할지 설정합니다."
DiscordCommandPrefix = "디스코드 봇 호출 명령어"
DiscordCommandPrefixTooltip = "디스코드 봇 호출 명령어를 설정합니다."

PalworldConfig = "팰월드 설정"
EnablePalworldRcon = "팰월드 RCON 호출 기능을 사용합니다. (PalWorldSettings.ini의 RCONEnable 값을 미리 true로 설정해주세요.)"
PalworldRconHost = "팰월드 RCON 호스트"
PalworldRconHostTooltip = "팰월드 서버가 실행된 서버의 주소를 입력하세요."
PalworldRconPort = "팰월드 RCON 포트"
PalworldRconPortTooltip = "PalWorldSettings.ini 파일에 설정된 RCONPort 값을 입력하세요. (포트포워딩이나 리버스 프록시를 이용해 변경하셨으면 해당 포트를 입력하세요.)"
PalworldAdminPassword = "팰월드 관리자 비밀번호"
PalworldAdminPasswordTooltip = "PalWorldSettings.ini 파일에 설정된 AdminPassword 값을 입력하세요."
PalworldServerFilePath = "팰월드 서버 파일 경로"
PalworldServerFilePathTooltip = "팰월드 서버가 실행된 파일의 경로를 입력하세요."
PalworldServerExecuteFlags = "팰월드 서버 실행 플래그"
PalworldServerExecuteFlagsTooltip = "팰월드 서버가 실행될 때 사용할 플래그를 입력하세요."

DiscordChannelConfig = "디스코드 채널 설정"
DiscordDashboardChannelID = "대시보드 채널 ID"
DiscordDashboardChannelIDTooltip = "대시보드 기능을 이용하기 위한 채널 ID를 입력하세요. 입력하지 않으면 해당 기능을 사용하지 않습니다. 채널 ID를 확인하는 방법은 현재 마우스를 올리고 있는 ? 버튼을 클릭하시면 확인하실 수 있습니다."
DiscordLogChannelID = "로그 채널 ID"
DiscordLogChannelIDTooltip = "유저의 접속/종료 기록을 확인하기 위한 채널 ID를 입력하세요. 입력하지 않으면 해당 기능을 사용하지 않습니다. 채널 ID를 확인하는 방법은 현재 마우스를 올리고 있는 ? 버튼을 클릭하시면 확인하실 수 있습니다."
DiscordDashboardOnlinePlayersMessageID = "온라인 상태 대시보드 Message ID"
DiscordDashboardOnlinePlayersMessageIDTooltip = "자동으로 설정되는 값입니다. 필요한 경우가 아니라면 수정하지 마세요."
DiscordDashboardPalworldConfigMessageID = "팰월드 설정 대시보드 Message ID"
DiscordDashboardPalworldConfigMessageIDTooltip = "자동으로 설정되는 값입니다. 필요한 경우가 아니라면 수정하지 마세요."
DiscordDashboardBotConfigMessageID = "봇 설정 대시보드 Message ID"
DiscordDashboardBotConfigMessageIDTooltip = "자동으로 설정되는 값입니다. 필요한 경우가 아니라면 수정하지 마세요."

DiscordCommandAliases = "디스코드 커맨드 커스터마이징"
DiscordCommandAliasKickTooltip = "유저를 1회 강퇴하는 커맨드를 커스텀 합니다."
DiscordCommandAliasBanTooltip = "유저를 차단하는 커맨드를 커스텀 합니다."
DiscordCommandAliasBroadcastTooltip = "모든 유저에게 메시지를 전송하는 커맨드를 커스텀 합니다. (영어만 가능)"
DiscordCommandAliasShutdownTooltip = "서버를 일정 시간 후 종료하는 커맨드를 커스텀 합니다."
DiscordCommandAliasDoExitTooltip = "서버를 강제 종료하는 커맨드를 커스텀 합니다."
DiscordCommandAliasSaveTooltip = "서버를 저장하는 커맨드를 커스텀 합니다."
DiscordCommandAliasStartServerTooltip = "서버를 실행하는 커맨드를 커스텀 합니다."

Close = "닫기"
Confirm = "확인"
Save = "저장"
}
63 changes: 61 additions & 2 deletions src/web/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func Listen(port int) error {
"WEB_SERVER_ENABLED": config.WEB_SERVER_ENABLED,
"WEB_SERVER_PORT": config.WEB_SERVER_PORT,

"LANGUAGE": config.LANGUAGE,
"LANGUAGES": i18n.Languages,
"LANGUAGE": config.LANGUAGE,

"DISCORD_BOT_ENABLED": config.DISCORD_BOT_ENABLED,
"DISCORD_BOT_TOKEN": config.DISCORD_BOT_TOKEN,
Expand All @@ -51,6 +50,66 @@ func Listen(port int) error {
"DISCORD_DASHBOARD_PALWORLD_CONFIG_MESSAGE_ID": config.DISCORD_DASHBOARD_PALWORLD_CONFIG_MESSAGE_ID,
"DISCORD_DASHBOARD_BOT_CONFIG_MESSAGE_ID": config.DISCORD_DASHBOARD_BOT_CONFIG_MESSAGE_ID,
},
"i18n": fiber.Map{
"WebConfig": i18n.WebConfig,
"EnableWebServer": i18n.EnableWebServer,
"EnableWebServerDisablePrompt": i18n.EnableWebServerDisablePrompt,
"WebServerPort": i18n.WebServerPort,
"WebServerPortTooltip": i18n.WebServerPortTooltip,

"Language": i18n.Language,
"Languages": i18n.Languages,
"SelectLanguage": i18n.SelectLanguage,

"DiscordBotConfig": i18n.DiscordBotConfig,
"EnableDiscordBot": i18n.EnableDiscordBot,
"DiscordBotToken": i18n.DiscordBotToken,
"DiscordBotTokenTooltip": i18n.DiscordBotTokenTooltip,
"DiscordAdminUsernames": i18n.DiscordAdminUsernames,
"DiscordAdminUsernamesTooltip": i18n.DiscordAdminUsernamesTooltip,
"DiscordCommandCaseSensitive": i18n.DiscordCommandCaseSensitive,
"DiscordCommandCaseSensitiveTooltip": i18n.DiscordCommandCaseSensitiveTooltip,
"DiscordCommandPrefix": i18n.DiscordCommandPrefix,
"DiscordCommandPrefixTooltip": i18n.DiscordCommandPrefixTooltip,

"PalworldConfig": i18n.PalworldConfig,
"EnablePalworldRcon": i18n.EnablePalworldRcon,
"PalworldRconHost": i18n.PalworldRconHost,
"PalworldRconHostTooltip": i18n.PalworldRconHostTooltip,
"PalworldRconPort": i18n.PalworldRconPort,
"PalworldRconPortTooltip": i18n.PalworldRconPortTooltip,
"PalworldAdminPassword": i18n.PalworldAdminPassword,
"PalworldAdminPasswordTooltip": i18n.PalworldAdminPasswordTooltip,
"PalworldServerFilePath": i18n.PalworldServerFilePath,
"PalworldServerFilePathTooltip": i18n.PalworldServerFilePathTooltip,
"PalworldServerExecuteFlags": i18n.PalworldServerExecuteFlags,
"PalworldServerExecuteFlagsTooltip": i18n.PalworldServerExecuteFlagsTooltip,

"DiscordChannelConfig": i18n.DiscordChannelConfig,
"DiscordDashboardChannelID": i18n.DiscordDashboardChannelID,
"DiscordDashboardChannelIDTooltip": i18n.DiscordDashboardChannelIDTooltip,
"DiscordLogChannelID": i18n.DiscordLogChannelID,
"DiscordLogChannelIDTooltip": i18n.DiscordLogChannelIDTooltip,
"DiscordDashboardOnlinePlayersMessageID": i18n.DiscordDashboardOnlinePlayersMessageID,
"DiscordDashboardOnlinePlayersMessageIDTooltip": i18n.DiscordDashboardOnlinePlayersMessageIDTooltip,
"DiscordDashboardPalworldConfigMessageID": i18n.DiscordDashboardPalworldConfigMessageID,
"DiscordDashboardPalworldConfigMessageIDTooltip": i18n.DiscordDashboardPalworldConfigMessageIDTooltip,
"DiscordDashboardBotConfigMessageID": i18n.DiscordDashboardBotConfigMessageID,
"DiscordDashboardBotConfigMessageIDTooltip": i18n.DiscordDashboardBotConfigMessageIDTooltip,

"DiscordCommandAliases": i18n.DiscordCommandAliases,
"DiscordCommandAliasKickTooltip": i18n.DiscordCommandAliasKickTooltip,
"DiscordCommandAliasBanTooltip": i18n.DiscordCommandAliasBanTooltip,
"DiscordCommandAliasBroadcastTooltip": i18n.DiscordCommandAliasBroadcastTooltip,
"DiscordCommandAliasShutdownTooltip": i18n.DiscordCommandAliasShutdownTooltip,
"DiscordCommandAliasDoExitTooltip": i18n.DiscordCommandAliasDoExitTooltip,
"DiscordCommandAliasSaveTooltip": i18n.DiscordCommandAliasSaveTooltip,
"DiscordCommandAliasStartServerTooltip": i18n.DiscordCommandAliasStartServerTooltip,

"Close": i18n.Close,
"Confirm": i18n.Confirm,
"Save": i18n.Save,
},
})
})

Expand Down
9 changes: 9 additions & 0 deletions src/web/public/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Input extends HTMLElement {
input = document.createElement('input');
label = document.createElement('label');
tooltip = document.createElement('button');
tooltipClickHref = '';
value = false;

constructor() { super(); }
Expand Down Expand Up @@ -73,6 +74,14 @@ class Input extends HTMLElement {
this.tooltip.setAttribute('title', this.getAttribute('tooltip'));
this.tooltip.style.border = 'none';
this.tooltip.style.borderRadius = '50%';

if (!this.getAttribute('tooltip-click-href')) {
return;
}

this.tooltip.addEventListener('click', () => {
window.open(this.getAttribute('tooltip-click-href'), '_blank');
})
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/web/public/components/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Switch extends HTMLElement {

turnOffPrompt = '';
modalOpenButton = document.createElement('button');
close = 'Close';
confirm = 'Confirm';

constructor() { super(); }

Expand Down Expand Up @@ -122,12 +124,12 @@ class Switch extends HTMLElement {
modalClose.type = 'button';
modalClose.className = 'btn btn-secondary';
modalClose.setAttribute('data-bs-dismiss', 'modal');
modalClose.textContent = 'Close';
modalClose.textContent = this.getAttribute('close') || 'Close';

const modalConfirm = document.createElement('button');
modalConfirm.type = 'button';
modalConfirm.className = 'btn btn-primary';
modalConfirm.textContent = 'Confirm';
modalConfirm.textContent = this.getAttribute('confirm') || 'Confirm';
modalConfirm.addEventListener('click', () => {
this.checked = false;
this.checkbox.checked = false;
Expand Down
Loading