Skip to content

Commit

Permalink
[bug][alert-12865] translate alert input field tips to chinese when u…
Browse files Browse the repository at this point in the history
…sing chinese (#12879)

* submit email ding talk changes

* submit alert messages

* submit format

* submit format
  • Loading branch information
Tianqi-Dotes authored Nov 14, 2022
1 parent 403c6a6 commit 250d81b
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to Apache Software Foundation (ASF) under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Apache Software Foundation (ASF) licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.dolphinscheduler.alert.api;

import java.util.Locale;

import org.springframework.context.i18n.LocaleContextHolder;

public enum AlertInputTips {

PASSWORD("if enable use authentication, you need input password", "如果开启鉴权校验,则需要输入密码"),
USERNAME("if enable use authentication, you need input user", "如果开启鉴权校验,则需要输入账号"),
RECEIVERS("please input receivers", "请输入收件人"),
URL("input request URL", "请输入请求的URL"),
HEADER("input request headers as JSON format", "请输入JSON格式的请求头"),
JSON_BODY("input request body as JSON format", "请输入JSON格式的请求体"),
FIELD_NAME("input alert msg field name", "请输入告警信息的内容字段名称"),
HTTP_METHOD("input request type POST or GET", "请输入HTTP请求类型POST或GET"),
CUSTOMIZED_PARAMS("the custom parameters passed when calling scripts", "请输入调用脚本时传入的自定义参数"),
SCRIPT_PATH("the absolute script path under alert-server, and make sure access rights",
"请输入alert-server机器的脚本的绝对路径,并确保文件有权接入"),
WEBHOOK("input WebHook Url", "请输入webhook的url"),
BOT_NAME("input the bot username", "请输入bot的名称"),
BOT_TOKEN("input bot access token", "请输入bot的接入token"),
CHANNEL_ID("input telegram channel chat id", "请输入telegram的频道chat id"),
ROOM_ID("input the room ID the alert message send to", "请输入告警信息发送的room ID"),
RECIPIENT_USER_ID("input the person ID of the alert message recipient", "请输入告警信息接收人的person ID"),
RECIPIENT_EMAIL("input the email address of the alert message recipient", "请输入告警信息接收人的email地址"),
WEBEX_MENTION_USERS(
"use `,`(eng commas) to separate multiple emails, to specify the person you mention in the room",
"使用 `, `来分割多个email,来指出在房间中要@的人"),
CORP_ID("please input corp id", "请输入corp id"),
SECRET("please input secret", "请输入secret"),
WECHAT_MENTION_USERS("use `|` to separate userIds and `@all` to everyone", "使用`|`来分割userId或使用`@all`来提到所有人"),
WECHAT_AGENT_ID("please input agent id or chat id", "请输入agent id或chat id"),
;

private final String enMsg;
private final String zhMsg;

AlertInputTips(String enMsg, String zhMsg) {
this.enMsg = enMsg;
this.zhMsg = zhMsg;
}

public String getMsg() {
if (Locale.SIMPLIFIED_CHINESE.getLanguage().equals(LocaleContextHolder.getLocale().getLanguage())) {
return this.zhMsg;
} else {
return this.enMsg;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.PasswordParam;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
Expand Down Expand Up @@ -134,7 +135,7 @@ public List<PluginParams> params() {
.build();
PasswordParam passwordParam = PasswordParam
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password")
.setPlaceholder(AlertInputTips.PASSWORD.getMsg())
.build();

return Arrays.asList(webHookParam, keywordParam, secretParam, msgTypeParam, atMobilesParam, atUserIdsParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertConstants;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.alert.api.ShowType;
import org.apache.dolphinscheduler.spi.params.PasswordParam;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
Expand Down Expand Up @@ -52,7 +53,7 @@ public List<PluginParams> params() {
InputParam receivesParam = InputParam
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS,
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
.setPlaceholder("please input receives")
.setPlaceholder(AlertInputTips.RECEIVERS.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
Expand Down Expand Up @@ -90,12 +91,12 @@ public List<PluginParams> params() {
.build();

InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, MailParamsConstants.MAIL_USER)
.setPlaceholder("if enable use authentication, you need input user")
.setPlaceholder(AlertInputTips.USERNAME.getMsg())
.build();

PasswordParam mailPassword =
PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
.setPlaceholder("if enable use authentication, you need input password")
.setPlaceholder(AlertInputTips.PASSWORD.getMsg())
.build();

RadioParam enableTls = RadioParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.PasswordParam;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
Expand Down Expand Up @@ -82,7 +83,7 @@ public List<PluginParams> params() {
.build();
PasswordParam passwordParam = PasswordParam
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password")
.setPlaceholder(AlertInputTips.PASSWORD.getMsg())
.build();

return Arrays.asList(webHookParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.params.input.InputParam;
Expand All @@ -40,39 +41,39 @@ public String name() {
public List<PluginParams> params() {

InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL)
.setPlaceholder("input request URL")
.setPlaceholder(AlertInputTips.URL.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();

InputParam headerParams =
InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
.setPlaceholder("input request headers as JSON format ")
.setPlaceholder(AlertInputTips.HEADER.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();

InputParam bodyParams =
InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
.setPlaceholder("input request body as JSON format ")
.setPlaceholder(AlertInputTips.JSON_BODY.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();

InputParam contentField =
InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
.setPlaceholder("input alert msg field name")
.setPlaceholder(AlertInputTips.FIELD_NAME.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();

InputParam requestType =
InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
.setPlaceholder("input request type POST or GET")
.setPlaceholder(AlertInputTips.HTTP_METHOD.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
Expand Down Expand Up @@ -46,17 +47,15 @@ public List<PluginParams> params() {
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.setPlaceholder(
"please enter your custom parameters, which will be passed to you when calling your script")
.setPlaceholder(AlertInputTips.CUSTOMIZED_PARAMS.getMsg())
.build();
// need check file type and file exist
InputParam scriptPathParam =
InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("please upload the file to the disk directory of the alert server,"
+ " and ensure that the path is absolute and has the corresponding access rights")
.setPlaceholder(AlertInputTips.SCRIPT_PATH.getMsg())
.build();

RadioParam scriptTypeParams = RadioParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.params.input.InputParam;
Expand All @@ -45,14 +46,14 @@ public List<PluginParams> params() {
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("Input WebHook Url")
.setPlaceholder(AlertInputTips.WEBHOOK.getMsg())
.build();

InputParam botName = InputParam.newBuilder(SlackParamsConstants.SLACK_BOT_NAME, SlackParamsConstants.SLACK_BOT)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("Input the bot username")
.setPlaceholder(AlertInputTips.BOT_NAME.getMsg())
.build();

paramsList.add(webHookParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.PasswordParam;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
Expand Down Expand Up @@ -58,23 +59,23 @@ public List<PluginParams> params() {
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("telegram web hook")
.setPlaceholder(AlertInputTips.WEBHOOK.getMsg())
.build();

InputParam botTokenParam = InputParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN, TelegramParamsConstants.TELEGRAM_BOT_TOKEN)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("telegram bot token")
.setPlaceholder(AlertInputTips.BOT_TOKEN.getMsg())
.build();

InputParam chatIdParam = InputParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_CHAT_ID, TelegramParamsConstants.TELEGRAM_CHAT_ID)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("telegram channel chat id")
.setPlaceholder(AlertInputTips.CHANNEL_ID.getMsg())
.build();

SelectParam parseMode = SelectParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
Expand All @@ -44,7 +45,7 @@ public List<PluginParams> params() {
InputParam botAccessToken = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN,
WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
.setPlaceholder("Please enter the robot's access token you were given")
.setPlaceholder(AlertInputTips.BOT_TOKEN.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
Expand All @@ -53,7 +54,7 @@ public List<PluginParams> params() {
InputParam roomId = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID,
WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
.setPlaceholder("The room ID of the message")
.setPlaceholder(AlertInputTips.ROOM_ID.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
Expand All @@ -62,7 +63,7 @@ public List<PluginParams> params() {
InputParam toPersonId = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID,
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
.setPlaceholder("The person ID of the message recipient")
.setPlaceholder(AlertInputTips.RECIPIENT_USER_ID.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
Expand All @@ -71,7 +72,7 @@ public List<PluginParams> params() {
InputParam toPersonEmail = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL,
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
.setPlaceholder("The email address of the message recipient")
.setPlaceholder(AlertInputTips.RECIPIENT_EMAIL.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
Expand All @@ -80,7 +81,7 @@ public List<PluginParams> params() {
InputParam atSomeoneInRoom = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM,
WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
.setPlaceholder("use ,(eng commas) to separate multiple emails")
.setPlaceholder(AlertInputTips.WEBEX_MENTION_USERS.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertConstants;
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
import org.apache.dolphinscheduler.alert.api.ShowType;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
Expand All @@ -45,7 +46,7 @@ public List<PluginParams> params() {
InputParam corpIdParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
.setPlaceholder("please input corp id ")
.setPlaceholder(AlertInputTips.CORP_ID.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
Expand All @@ -54,7 +55,7 @@ public List<PluginParams> params() {
InputParam secretParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
.setPlaceholder("please input secret ")
.setPlaceholder(AlertInputTips.SECRET.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
Expand All @@ -63,7 +64,7 @@ public List<PluginParams> params() {
InputParam usersParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
.setPlaceholder("use `|` to separate userIds and `@all` to everyone ")
.setPlaceholder(AlertInputTips.WECHAT_MENTION_USERS.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
Expand All @@ -72,7 +73,7 @@ public List<PluginParams> params() {
InputParam agentIdParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
.setPlaceholder("please input agent id or chat id ")
.setPlaceholder(AlertInputTips.WECHAT_AGENT_ID.getMsg())
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
Expand Down

0 comments on commit 250d81b

Please sign in to comment.