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

[Improvement] internationalization message #3927

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 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
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
import org.springframework.http.converter.ResourceHttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;

import java.util.List;
import java.util.Locale;

/** Customize the SpringMVC configuration */
@Configuration
Expand All @@ -52,6 +55,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
HttpMethod.DELETE.name()
};

public static final String LOCALE_LANGUAGE_COOKIE = "language";

@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new ByteArrayHttpMessageConverter());
Expand Down Expand Up @@ -95,4 +100,16 @@ public void addInterceptors(InterceptorRegistry registry) {
.addInterceptor(uploadFileTypeInterceptor)
.addPathPatterns("/flink/app/upload", "/resource/upload");
}

@Bean(name = "localeResolver")
public LocaleResolver localeResolver() {
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
localeResolver.setCookieName(LOCALE_LANGUAGE_COOKIE);
// set default locale
localeResolver.setDefaultLocale(Locale.US);
// set language tag compliant
localeResolver.setLanguageTagCompliant(false);
return localeResolver;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Licensed to the 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.
* The 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.streampark.console.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum ApplicationMessageStatus implements Status {

HANDLER_UPLOAD_FILE_IS_NULL_ERROR(10840, "File to upload can't be null. Upload file failed.", "要上传的文件不能为空,上传文件失败"),
HANDLER_UPLOAD_FILE_TYPE_ILLEGAL_ERROR(10850,
"Illegal file type, Only support standard jar or python files. Upload file failed.",
"文件类型非法,仅支持标准jar或python文件 上传文件失败。"),

APP_CREATE_FAILED(10860, "create application failed.", "创建应用程序失败"),
APP_ID_NOT_EXISTS_ERROR(10870, "The application id={0} can't be found.", "找不到应用程序 id={0}"),
APP_ID_NOT_EXISTS_REVOKE_FAILED(10880, "The application id={0} can't be found, revoke failed.",
"找不到应用程序 id={0}, 撤销失败"),
APP_EXECUTE_MODE_NOT_EXISTS_ERROR(10890, "ExecutionMode can't be null.", "执行模式不能为空"),
APP_EXECUTE_MODE_OPERATION_DISABLE_ERROR(10900, "The FlinkExecutionMode [{0}] can't [{1}]!",
"Flink执行模式[{0}]无法{1}!"),
APP_NOT_EXISTS_ERROR(10920, "[StreamPark] {0} The application cannot be started repeatedly.",
"[StreamPark] {0} 应用程序无法重复启动。"),
APP_ACTION_REPEAT_START_ERROR(10930, "[StreamPark] {0} The application cannot be started repeatedly.",
"[StreamPark] {0} 应用程序无法重复启动。"),
APP_ACTION_SAME_TASK_IN_ALREADY_RUN_ERROR(10940,
"[StreamPark] The same task name is already running in the yarn queue",
"[StreamPark] 相同的任务名称已在Yarn队列中运行"),
APP_ACTION_YARN_CLUSTER_STATE_CHECK(10950, "[StreamPark] The yarn cluster service state is {0}, please check it",
"[StreamPark] Yarn 集群服务状态为 {0},请检查一下"),
APP_CONFIG_FILE_TYPE_ILLEGALLY(10960, "application' config error. must be (.properties|.yaml|.yml |.conf)",
"应用程序配置错误,必须是(.properties.yaml|.YML|.conf)"),

APP_JOB_IS_INVALID(10970, "The job is invalid, or the job cannot be built while it is running",
"作业无效,或者在作业运行时无法生成作业"),
APP_JOB_EXECUTION_MODE_ILLEGALLY(10980, "Job executionMode must be kubernetes-session|kubernetes-application.",
"Job 执行模式必须是 Kubernetes-session 或 Kubernetes-application"),
APP_PY_FLINK_FILE_IS_NULL(10990, "pyflink file can't be null, start application failed.",
"PyFlink 文件不能为空,启动应用程序失败"),
APP_PY_FLINK_FILE_TYPE_ILLEGALLY(101000,
"pyflink format error, must be a \".py\" suffix, start application failed.",
"PyFlink格式错误,必须是 \".py\" 后缀,启动应用程序失败"),

APP_QUEUE_LABEL_IN_TEAM_ILLEGALLY(101010,
"Queue label [{0}] isn't available for teamId [{1}], please add it into the team first.",
"队列标签 [{0}] 不适用于 teamId [{1}],请先将其添加到团队中。"),

APP_QUEUE_LABEL_IN_DATABASE_ILLEGALLY(101020,
"Queue label [{0}] isn't available in database, please add it first.",
"队列标签[{0}]在数据库中不可用,请先添加它"),

APP_NAME_REPEAT_COPY_FAILED(101030,
"Application names can't be repeated, copy application failed.",
"应用程序名称不能重复,复制应用程序失败。"),

APP_FLINK_CLUSTER_NOT_RUNNING_UPDATE_FAILED(101040,
"update failed, because bind flink cluster not running",
"更新失败,因为绑定Flink集群未运行"),

APP_BUILD_RESOURCE_GROUP_FAILED(101050, "Parse resource group failed", "分析资源组失败"),

EXTERNAL_LINK_PARAM_EXISTING_ERROR(101060, "{0}:{1} is already existing.", "{0}:{1}已经能存在"),

API_NOT_SUPPORT(101150, "current api unsupported: {0}", "当前API不受支持: {0}"),
;
private final int code;
private final String enMsg;
private final String zhMsg;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the 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.
* The 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.streampark.console.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum CommonStatus implements Status {

SUCCESS(0, "success", "成功"),
UNKNOWN_ERROR(1, "unknown error: {0}", "未知错误: {0}"),

PROJECT(10, "Project", "项目"),
TEAM(11, "Team", "团队"),
VARIABLE(12, "Variable", "变量"),
APPLICATION(13, "Application", "应用程序"),
FLINK_CLUSTERS(14, "Flink Clusters", "Flink集群"),

;

private final int code;
private final String enMsg;
private final String zhMsg;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Licensed to the 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.
* The 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.streampark.console.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum FlinkMessageStatus implements Status {

FLINK_ENV_SQL_CLIENT_JAR_NOT_EXIST(10430, "[StreamPark] can't found streampark-flink-sqlclient jar in {0}",
"[StreamPark] 在{0}中找不到 streampark-flink-sqlclient jar"),
FLINK_ENV_SQL_CLIENT_JAR_MULTIPLE_EXIST(10440, "[StreamPark] found multiple streampark-flink-sqlclient jar in {0}",
"[StreamPark] 在 {0} 中发现多个 streampark-flink-sqlclient jar"),
FLINK_ENV_FILE_OR_DIR_NOT_EXIST(10450, "[StreamPark] file or directory [{0}] no exists. please check.",
"[StreamPark] 文件或目录 [{0}] 不存在,请检查"),
FLINK_ENV_FLINK_VERSION_NOT_FOUND(10460, "[StreamPark] can no found flink {0} version",
"[StreamPark] 无法找到Flink {0} 版本"),
FLINK_ENV_FLINK_VERSION_UNSUPPORT(10470, "[StreamPark] Unsupported flink version: {0}",
"[StreamPark] 不支持的Flink版本:{0}"),
FLINK_ENV_HOME_NOT_EXIST(10480, "The flink home does not exist, please check.", "Flink Home 不存在,请检查"),
FLINK_ENV_HOME_EXIST_CLUSTER_USE(10490, "The flink home is still in use by some flink cluster, please check.",
"Flink Home 还在被一些Flink集群使用 请检查"),
FLINK_ENV_HOME_EXIST_APP_USE(10500, "The flink home is still in use by some application, please check.",
"Flink Home 仍在被某些应用程序使用 请检查"),

FLINK_ENV_HOME_IS_DEFAULT_SET(10510, "The flink home is set as default, please change it first.",
"Flink Home 设置为默认设置,请先更改"),

FLINK_ENV_CONNECTOR_NULL_ERROR(10520, "The flink connector is null.",
"Flink连接器为空"),

FLINK_ENV_DIRECTORY_NOT_CONFIG_FILE(10530, "cannot find {0} in flink/conf ",
"在 flink/conf 中找不到{0}"),

FLINK_CLUSTER_UNAVAILABLE(10540, "[StreamPark] The target cluster is unavailable, please check!, please check it",
"[StreamPark] 目标集群不可用,请检查!"),
FLINK_CLUSTER_NOT_EXIST(10550, "[StreamPark] The flink cluster don't exist, please check it",
"[StreamPark] Flink 集群不存在,请检查"),
FLINK_CLUSTER_NOT_RUNNING(10560, "[StreamPark] The flink cluster not running, please start it",
"[StreamPark] Flink集群未运行,请启动它"),
FLINK_CLUSTER_NOT_ACTIVE(10570, "[StreamPark] Current cluster is not active, please check!",
"[StreamPark] 当前集群未处于活动状态,请检查"),
FLINK_CLUSTER_DEPLOY_FAILED(10580,
"[StreamPark] Deploy cluster failed, unknown reason,please check you params or StreamPark error log.",
"[StreamPark] 部署集群失败,原因不明,请检查您的参数或StreamPark错误日志"),
FLINK_CLUSTER_ID_CANNOT_FIND_ERROR(10590,
"The [clusterId={0}] cannot be find, maybe the clusterId is wrong or the cluster has been deleted. Please contact the Admin.",
"找不到[集群ID={0}],可能是集群Id错误或集群已被删除。请联系管理员。"),
FLINK_CLUSTER_ID_EMPTY_ERROR(10600, "[StreamPark] The clusterId can not be empty!", "[StreamPark] 集群Id不能为空!"),
FLINK_CLUSTER_CLOSE_FAILED(10610, "[StreamPark] Shutdown cluster failed: {0}", "[StreamPark] 关闭群集失败: {0}"),
FLINK_CLUSTER_DELETE_RUNNING_CLUSTER_FAILED(10620,
"[StreamPark] Flink cluster is running, cannot be delete, please check.", "[StreamPark] Flink集群正在运行,无法删除 请检查。"),
FLINK_CLUSTER_EXIST_APP_DELETE_FAILED(10630,
"[StreamPark] Some app exist on this cluster, the cluster cannot be delete, please check.",
"[StreamPark] 此集群上存在某些应用程序,无法删除该集群 请检查"),
FLINK_CLUSTER_EXIST_RUN_TASK_CLOSE_FAILED(10640,
"[StreamPark] Some app is running on this cluster, the cluster cannot be shutdown",
"[StreamPark] 某些应用程序正在此集群上运行,无法关闭集群"),

FLINK_CLUSTER_SHUTDOWN_RESPONSE_FAILED(10650,
"Get shutdown response failed",
"获取关机响应失败"),

FLINK_GATEWAY_NAME_EXIST(10660, "gateway name already exists", "网关名称已存在"),
FLINK_GATEWAY_GET_VERSION_FAILED(10670, "get gateway version failed", "获取网关版本失败"),

FLINk_APP_IS_NULL(10671, "Invalid operation, application is null.", "操作无效,应用程序为空"),
FLINk_SQL_APPID_OR_TEAM_ID_IS_NULL(10680, "Permission denied, appId and teamId cannot be null.",
"权限被拒绝,应用Id和团队Id不能为空"),
FLINK_SQL_IS_NULL_UPDATE_FAILED(10690, "Flink sql is null, update flink sql job failed.",
"FlinkSql为空,更新FlinkSQL作业失败"),
FLINK_SQL_BACKUP_IS_NULL_ROLLBACK_FAILED(10700, "Application backup can't be null. Rollback flink sql failed.",
"应用程序备份不能为为空,回滚FlinkSql失败"),

;
private final int code;
private final String enMsg;
private final String zhMsg;

}
Loading
Loading