Merge pull request #2812 from louislam/remove-translate-keys

Remove untranslatable keys and notification list optimization
pull/2835/head
Louis Lam 2 years ago committed by GitHub
commit 81a829bda7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,10 @@
<div class="mb-3"> <div class="mb-3">
<label for="notification-type" class="form-label">{{ $t("Notification Type") }}</label> <label for="notification-type" class="form-label">{{ $t("Notification Type") }}</label>
<select id="notification-type" v-model="notification.type" class="form-select"> <select id="notification-type" v-model="notification.type" class="form-select">
<option v-for="type in notificationTypes" :key="type" :value="type">{{ $t(type) }}</option> <option v-for="(name, type) in notificationNameList.regularList" :key="type" :value="type">{{ name }}</option>
<optgroup :label="$t('notificationRegional')">
<option v-for="(name, type) in notificationNameList.regionalList" :key="type" :value="type">{{ name }}</option>
</optgroup>
</select> </select>
</div> </div>
@ -67,7 +70,7 @@
</Confirm> </Confirm>
</template> </template>
<script lang="ts"> <script>
import { Modal } from "bootstrap"; import { Modal } from "bootstrap";
import Confirm from "./Confirm.vue"; import Confirm from "./Confirm.vue";
@ -103,7 +106,91 @@ export default {
return null; return null;
} }
return NotificationFormList[this.notification.type]; return NotificationFormList[this.notification.type];
} },
notificationNameList() {
let regularList = {
"alerta": "Alerta",
"AlertNow": "AlertNow",
"apprise": this.$t("apprise"),
"Bark": "Bark",
"clicksendsms": "ClickSend SMS",
"discord": "Discord",
"GoogleChat": "Google Chat (Google Workspace)",
"gorush": "Gorush",
"gotify": "Gotify",
"HomeAssistant": "Home Assistant",
"Kook": "Kook",
"line": "LINE Messenger",
"LineNotify": "LINE Notify",
"lunasea": "LunaSea",
"matrix": "Matrix",
"mattermost": "Mattermost",
"ntfy": "Ntfy",
"octopush": "Octopush",
"OneBot": "OneBot",
"PagerDuty": "PagerDuty",
"pushbullet": "Pushbullet",
"PushByTechulus": "Push by Techulus",
"pushover": "Pushover",
"pushy": "Pushy",
"rocket.chat": "Rocket.Chat",
"signal": "Signal",
"slack": "Slack",
"squadcast": "SquadCast",
"SMSEagle": "SMSEagle",
"smtp": this.$t("smtp"),
"stackfield": "Stackfield",
"teams": "Microsoft Teams",
"telegram": "Telegram",
"Splunk": "Splunk",
"webhook": "Webhook",
"GoAlert": "GoAlert",
"ZohoCliq": "ZohoCliq"
};
// Put notifications here if it's not supported in most regions or its documentation is not in English
let regionalList = {
"AliyunSMS": "AliyunSMS (阿里云短信服务)",
"DingDing": "DingDing (钉钉自定义机器人)",
"Feishu": "Feishu (飞书)",
"FreeMobile": "FreeMobile (mobile.free.fr)",
"PushDeer": "PushDeer",
"promosms": "PromoSMS",
"serwersms": "SerwerSMS.pl",
"SMSManager": "SmsManager (smsmanager.cz)",
"WeCom": "WeCom (企业微信群机器人)",
"ServerChan": "ServerChan (Server酱)",
};
// Sort by notification name
// No idea how, but it works
// https://stackoverflow.com/questions/1069666/sorting-object-property-by-values
let sort = (list2) => {
return Object.entries(list2)
.sort(([ , a ], [ , b ]) => a.localeCompare(b))
.reduce((r, [ k, v ]) => ({
...r,
[k]: v
}), {});
};
return {
regularList: sort(regularList),
regionalList: sort(regionalList),
};
},
notificationFullNameList() {
let list = {};
for (let [ key, value ] of Object.entries(this.notificationNameList.regularList)) {
list[key] = value;
}
for (let [ key, value ] of Object.entries(this.notificationNameList.regionalList)) {
list[key] = value;
}
return list;
},
}, },
watch: { watch: {
@ -203,11 +290,12 @@ export default {
* @return {string} * @return {string}
*/ */
getUniqueDefaultName(notificationKey) { getUniqueDefaultName(notificationKey) {
let index = 1; let index = 1;
let name = ""; let name = "";
do { do {
name = this.$t("defaultNotificationName", { name = this.$t("defaultNotificationName", {
notification: this.$t(notificationKey).replace(/\(.+\)/, "").trim(), notification: this.notificationFullNameList[notificationKey].replace(/\(.+\)/, "").trim(),
number: index++ number: index++
}); });
} while (this.$root.notificationList.find(it => it.name === name)); } while (this.$root.notificationList.find(it => it.name === name));

@ -16,7 +16,7 @@
<div class="mb-3"> <div class="mb-3">
<label for="gorush-platform" class="form-label">{{ $t("Platform") }}</label><span style="color: red;"><sup>*</sup></span> <label for="gorush-platform" class="form-label">{{ $t("Platform") }}</label><span style="color: red;"><sup>*</sup></span>
<select id="gorush-platform" v-model="$parent.notification.gorushPlatform" class="form-select"> <select id="gorush-platform" v-model="$parent.notification.gorushPlatform" class="form-select">
<option value="ios">{{ $t("iOS") }}</option> <option value="ios">iOS</option>
<option value="android">{{ $t("Android") }}</option> <option value="android">{{ $t("Android") }}</option>
<option value="huawei">{{ $t("Huawei") }}</option> <option value="huawei">{{ $t("Huawei") }}</option>
</select> </select>

@ -186,7 +186,6 @@
"defaultNotificationName": "My {notification} Alert ({number})", "defaultNotificationName": "My {notification} Alert ({number})",
"here": "here", "here": "here",
"Required": "Required", "Required": "Required",
"webhook": "Webhook",
"Post URL": "Post URL", "Post URL": "Post URL",
"Content Type": "Content Type", "Content Type": "Content Type",
"webhookJsonDesc": "{0} is good for any modern HTTP servers such as Express.js", "webhookJsonDesc": "{0} is good for any modern HTTP servers such as Express.js",
@ -359,8 +358,6 @@
"Domain": "Domain", "Domain": "Domain",
"Workstation": "Workstation", "Workstation": "Workstation",
"Packet Size": "Packet Size", "Packet Size": "Packet Size",
"telegram": "Telegram",
"ZohoCliq": "ZohoCliq",
"Bot Token": "Bot Token", "Bot Token": "Bot Token",
"wayToGetTelegramToken": "You can get a token from {0}.", "wayToGetTelegramToken": "You can get a token from {0}.",
"Chat ID": "Chat ID", "Chat ID": "Chat ID",
@ -388,7 +385,6 @@
"backupOutdatedWarning": "Deprecated: Since a lot of features were added and this backup feature is a bit unmaintained, it cannot generate or restore a complete backup.", "backupOutdatedWarning": "Deprecated: Since a lot of features were added and this backup feature is a bit unmaintained, it cannot generate or restore a complete backup.",
"backupRecommend": "Please backup the volume or the data folder (./data/) directly instead.", "backupRecommend": "Please backup the volume or the data folder (./data/) directly instead.",
"Optional": "Optional", "Optional": "Optional",
"squadcast": "Squadcast",
"or": "or", "or": "or",
"recurringInterval": "Interval", "recurringInterval": "Interval",
"Recurring": "Recurring", "Recurring": "Recurring",
@ -436,6 +432,7 @@
"uninstall": "Uninstall", "uninstall": "Uninstall",
"uninstalling": "Uninstalling", "uninstalling": "Uninstalling",
"confirmUninstallPlugin": "Are you sure want to uninstall this plugin?", "confirmUninstallPlugin": "Are you sure want to uninstall this plugin?",
"notificationRegional": "Regional",
"smtp": "Email (SMTP)", "smtp": "Email (SMTP)",
"secureOptionNone": "None / STARTTLS (25, 587)", "secureOptionNone": "None / STARTTLS (25, 587)",
"secureOptionTLS": "TLS (465)", "secureOptionTLS": "TLS (465)",
@ -530,28 +527,11 @@
"pushoversounds none": "None (silent)", "pushoversounds none": "None (silent)",
"pushyAPIKey": "Secret API Key", "pushyAPIKey": "Secret API Key",
"pushyToken": "Device token", "pushyToken": "Device token",
"discord": "Discord",
"teams": "Microsoft Teams",
"signal": "Signal",
"gotify": "Gotify",
"slack": "Slack",
"rocket.chat": "Rocket.Chat",
"pushover": "Pushover",
"pushy": "Pushy",
"PushByTechulus": "Push by Techulus",
"octopush": "Octopush",
"promosms": "PromoSMS",
"clicksendsms": "ClickSend SMS",
"lunasea": "LunaSea",
"apprise": "Apprise (Support 50+ Notification services)", "apprise": "Apprise (Support 50+ Notification services)",
"GoogleChat": "Google Chat (Google Workspace only)", "GoogleChat": "Google Chat (Google Workspace only)",
"pushbullet": "Pushbullet",
"Kook": "Kook",
"wayToGetKookBotToken": "Create application and get your bot token at {0}", "wayToGetKookBotToken": "Create application and get your bot token at {0}",
"wayToGetKookGuildID": "Switch on 'Developer Mode' in Kook setting, and right click the guild to get its ID", "wayToGetKookGuildID": "Switch on 'Developer Mode' in Kook setting, and right click the guild to get its ID",
"Guild ID": "Guild ID", "Guild ID": "Guild ID",
"line": "Line Messenger",
"mattermost": "Mattermost",
"User Key": "User Key", "User Key": "User Key",
"Device": "Device", "Device": "Device",
"Message Title": "Message Title", "Message Title": "Message Title",
@ -586,12 +566,10 @@
"SendKey": "SendKey", "SendKey": "SendKey",
"SMSManager API Docs": "SMSManager API Docs ", "SMSManager API Docs": "SMSManager API Docs ",
"Gateway Type": "Gateway Type", "Gateway Type": "Gateway Type",
"SMSManager": "SMSManager",
"You can divide numbers with": "You can divide numbers with", "You can divide numbers with": "You can divide numbers with",
"Base URL": "Base URL", "Base URL": "Base URL",
"goAlertInfo": "GoAlert is a An open source application for on-call scheduling, automated escalations and notifications (like SMS or voice calls). Automatically engage the right person, the right way, and at the right time! {0}", "goAlertInfo": "GoAlert is a An open source application for on-call scheduling, automated escalations and notifications (like SMS or voice calls). Automatically engage the right person, the right way, and at the right time! {0}",
"goAlertIntegrationKeyInfo": "Get generic API integration key for the service in this format \"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\" usually the value of token parameter of copied URL.", "goAlertIntegrationKeyInfo": "Get generic API integration key for the service in this format \"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\" usually the value of token parameter of copied URL.",
"goAlert": "GoAlert",
"AccessKeyId": "AccessKey ID", "AccessKeyId": "AccessKey ID",
"SecretAccessKey": "AccessKey Secret", "SecretAccessKey": "AccessKey Secret",
"PhoneNumbers": "PhoneNumbers", "PhoneNumbers": "PhoneNumbers",
@ -606,7 +584,6 @@
"For safety, must use secret key": "For safety, must use secret key", "For safety, must use secret key": "For safety, must use secret key",
"Device Token": "Device Token", "Device Token": "Device Token",
"Platform": "Platform", "Platform": "Platform",
"iOS": "iOS",
"Android": "Android", "Android": "Android",
"Huawei": "Huawei", "Huawei": "Huawei",
"High": "High", "High": "High",
@ -617,7 +594,6 @@
"Proxy Protocol": "Proxy Protocol", "Proxy Protocol": "Proxy Protocol",
"Proxy Server": "Proxy Server", "Proxy Server": "Proxy Server",
"Proxy server has authentication": "Proxy server has authentication", "Proxy server has authentication": "Proxy server has authentication",
"matrix": "Matrix",
"promosmsTypeEco": "SMS ECO - cheap but slow and often overloaded. Limited only to Polish recipients.", "promosmsTypeEco": "SMS ECO - cheap but slow and often overloaded. Limited only to Polish recipients.",
"promosmsTypeFlash": "SMS FLASH - Message will automatically show on recipient device. Limited only to Polish recipients.", "promosmsTypeFlash": "SMS FLASH - Message will automatically show on recipient device. Limited only to Polish recipients.",
"promosmsTypeFull": "SMS FULL - Premium tier of SMS, You can use your Sender Name (You need to register name first). Reliable for alerts.", "promosmsTypeFull": "SMS FULL - Premium tier of SMS, You can use your Sender Name (You need to register name first). Reliable for alerts.",
@ -653,19 +629,15 @@
"do nothing": "do nothing", "do nothing": "do nothing",
"auto acknowledged": "auto acknowledged", "auto acknowledged": "auto acknowledged",
"auto resolve": "auto resolve", "auto resolve": "auto resolve",
"gorush": "Gorush",
"alerta": "Alerta",
"alertaApiEndpoint": "API Endpoint", "alertaApiEndpoint": "API Endpoint",
"alertaEnvironment": "Environment", "alertaEnvironment": "Environment",
"alertaApiKey": "API Key", "alertaApiKey": "API Key",
"alertaAlertState": "Alert State", "alertaAlertState": "Alert State",
"alertaRecoverState": "Recover State", "alertaRecoverState": "Recover State",
"serwersms": "SerwerSMS.pl",
"serwersmsAPIUser": "API Username (incl. webapi_ prefix)", "serwersmsAPIUser": "API Username (incl. webapi_ prefix)",
"serwersmsAPIPassword": "API Password", "serwersmsAPIPassword": "API Password",
"serwersmsPhoneNumber": "Phone number", "serwersmsPhoneNumber": "Phone number",
"serwersmsSenderName": "SMS Sender Name (registered via customer portal)", "serwersmsSenderName": "SMS Sender Name (registered via customer portal)",
"smseagle": "SMSEagle",
"smseagleTo": "Phone number(s)", "smseagleTo": "Phone number(s)",
"smseagleGroup": "Phonebook group name(s)", "smseagleGroup": "Phonebook group name(s)",
"smseagleContact": "Phonebook contact name(s)", "smseagleContact": "Phonebook contact name(s)",
@ -675,14 +647,12 @@
"smseagleUrl": "Your SMSEagle device URL", "smseagleUrl": "Your SMSEagle device URL",
"smseagleEncoding": "Send as Unicode", "smseagleEncoding": "Send as Unicode",
"smseaglePriority": "Message priority (0-9, default = 0)", "smseaglePriority": "Message priority (0-9, default = 0)",
"stackfield": "Stackfield",
"Recipient Number": "Recipient Number", "Recipient Number": "Recipient Number",
"From Name/Number": "From Name/Number", "From Name/Number": "From Name/Number",
"Leave blank to use a shared sender number.": "Leave blank to use a shared sender number.", "Leave blank to use a shared sender number.": "Leave blank to use a shared sender number.",
"Octopush API Version": "Octopush API Version", "Octopush API Version": "Octopush API Version",
"Legacy Octopush-DM": "Legacy Octopush-DM", "Legacy Octopush-DM": "Legacy Octopush-DM",
"ntfy Topic": "ntfy Topic", "ntfy Topic": "ntfy Topic",
"HomeAssistant": "Home Assistant",
"onebotHttpAddress": "OneBot HTTP Address", "onebotHttpAddress": "OneBot HTTP Address",
"onebotMessageType": "OneBot Message Type", "onebotMessageType": "OneBot Message Type",
"onebotGroupMessage": "Group", "onebotGroupMessage": "Group",

@ -272,7 +272,6 @@
"apprise": "Apprise (支持 50+ 种通知服务)", "apprise": "Apprise (支持 50+ 种通知服务)",
"GoogleChat": "Google Chat仅 Google Workspace", "GoogleChat": "Google Chat仅 Google Workspace",
"pushbullet": "Pushbullet", "pushbullet": "Pushbullet",
"AliyunSMS": "阿里云短信服务",
"Kook": "Kook", "Kook": "Kook",
"wayToGetKookBotToken": "在 {0} 创建应用并获取机器人 Token", "wayToGetKookBotToken": "在 {0} 创建应用并获取机器人 Token",
"wayToGetKookGuildID": "在 Kook 设置中打开“开发者模式”,然后右键点击频道可获取其 ID", "wayToGetKookGuildID": "在 Kook 设置中打开“开发者模式”,然后右键点击频道可获取其 ID",
@ -448,7 +447,6 @@
"Bark Endpoint": "Bark 接入点", "Bark Endpoint": "Bark 接入点",
"Bark Group": "Bark 群组", "Bark Group": "Bark 群组",
"Bark Sound": "Bark 铃声", "Bark Sound": "Bark 铃声",
"DingDing": "钉钉自定义机器人",
"WebHookUrl": "钉钉自定义机器人 Webhook 地址", "WebHookUrl": "钉钉自定义机器人 Webhook 地址",
"SecretKey": "钉钉自定义机器人加签密钥", "SecretKey": "钉钉自定义机器人加签密钥",
"For safety, must use secret key": "出于安全考虑,必须使用加签密钥", "For safety, must use secret key": "出于安全考虑,必须使用加签密钥",

Loading…
Cancel
Save