forked from TencentBlueKing/bk-turbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: turbo后台信息国际化 TencentBlueKing#86
- Loading branch information
Showing
6 changed files
with
173 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/backend/turbo/boot-turbo/src/main/resources/i18n/message_en_US.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
disttask-cc.desc=A brand-new, self-developed engine with zero intrusion and one-click acceleration offers faster speeds. It provides visual compilation charts to clearly control the entire process data. Features include support for PCH, Gcov, distributed preprocessing, and more. | ||
disttask-cc.recommendReason=A brand-new, self-developed engine with zero intrusion and one-click acceleration offers faster speeds. It provides visual compilation charts to clearly control the entire process data. Features include support for PCH, Gcov, distributed preprocessing, and more. | ||
disttask-cc.engineName=Linux-C/C++ Acceleration | ||
disttask-cc.paramConfig.queue_name=Priority Scheduling Area | ||
disttask-cc.paramConfig.queue_name.paramEnum.K8S\://gd=Shenzhen-K8S Cluster | ||
disttask-cc.paramConfig.queue_name.paramEnum.shenzhen=Shenzhen/Guangzhou | ||
disttask-cc.paramConfig.queue_name.paramEnum.shanghai=Shanghai/Nanjing | ||
disttask-cc.paramConfig.queue_name.paramEnum.chengdu=Chengdu/Chongqing | ||
disttask-cc.paramConfig.queue_name.paramEnum.tianjin=Beijing/Tianjin | ||
disttask-cc.paramConfig.worker_version.paramName=Builder Version | ||
disttask-cc.paramConfig.ccache_enabled.paramName=Enable Ccache | ||
|
||
disttask-ue4.desc=A self-developed engine for accelerating Unreal Engine builds across multiple platforms. Supports acceleration for Editor, Shader, Dedicated Servers, and more. | ||
disttask-ue4.recommendReason=A self-developed engine for accelerating Unreal Engine builds across multiple platforms. Supports acceleration for Editor, Shader, Dedicated Servers, and more. | ||
disttask-ue4.engineName=Unreal Engine Acceleration | ||
disttask-ue4.paramConfig.worker_version.paramName=Build Environment | ||
disttask-ue4.paramConfig.worker_version.paramEnum.win2019-pure-drived=Windows General Environment | ||
disttask-ue4.paramConfig.worker_version.paramEnum.macvm=MacOS General Environment | ||
disttask-ue4.paramConfig.worker_version.paramEnum.tlinux2.2-generic=TLinux2.2 General Environment | ||
disttask-ue4.paramConfig.queue_name=Acceleration Platform | ||
|
||
distcc.desc=【Deprecated】Traditional distcc approach, suitable for C/C++ compilation under Linux. | ||
distcc.engineName=distcc | ||
distcc.paramConfig.city.paramName=Priority Scheduling Area | ||
distcc.paramConfig.city.paramEnum.K8S\://gd=Shenzhen-K8S Cluster | ||
distcc.paramConfig.city.paramEnum.shenzhen=Shenzhen/Guangzhou | ||
distcc.paramConfig.city.paramEnum.shanghai=Shanghai/Nanjing | ||
distcc.paramConfig.city.paramEnum.chengdu=Chengdu/Chongqing | ||
distcc.paramConfig.city.paramEnum.tianjin=Beijing/Tianjin | ||
distcc.paramConfig.gcc_version.paramName=Builder Version | ||
distcc.paramConfig.ccache_enabled.paramName=Enable Ccache | ||
|
||
disttask-cc.displayFields.queue_name.fieldName=Acceleration Zone | ||
disttask-cc.displayFields.request_cpu.fieldName=Acceleration CPU Core | ||
disttask-cc.displayFields.worker_version.fieldName=Work Version | ||
disttask-cc.displayFields.client_version.fieldName=Client Version | ||
disttask-cc.displayFields.client_ip.fieldName=Initiating Node |
37 changes: 37 additions & 0 deletions
37
src/backend/turbo/boot-turbo/src/main/resources/i18n/message_zh_CN.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
disttask-cc.desc=全新自研引擎,零侵入一键加速,更快的速度,提供可视化编译图表,清晰掌控全流程数据。支持pch、gcov、分布式预处理等更多功能。 | ||
disttask-cc.recommendReason=全新自研引擎,零侵入一键加速,更快的速度,提供可视化编译图表,清晰掌控全流程数据。支持pch、gcov、分布式预处理等更多功能。 | ||
disttask-cc.engineName=Linux-C/C++ 加速 | ||
disttask-cc.paramConfig.queue_name.paramName=优先调度区域 | ||
disttask-cc.paramConfig.queue_name.paramEnum.K8S\://gd=深圳K8S集群(推荐) | ||
disttask-cc.paramConfig.queue_name.paramEnum.shenzhen=深圳/广州 | ||
disttask-cc.paramConfig.queue_name.paramEnum.shanghai=上海/南京 | ||
disttask-cc.paramConfig.queue_name.paramEnum.chengdu=成都/重庆 | ||
disttask-cc.paramConfig.queue_name.paramEnum.tianjin=北京/天津 | ||
disttask-cc.paramConfig.worker_version.paramName=编译器版本 | ||
disttask-cc.paramConfig.ccache_enabled.paramName=是否启用Ccache | ||
|
||
disttask-ue4.desc=自研引擎,多平台下的 UE4 构建加速。支持 Editor、Shader、Dedicated Servers 等加速。 | ||
disttask-ue4.recommendReason=自研引擎,多平台下的 UE4 构建加速。支持 Editor、Shader、Dedicated Servers 等加速。 | ||
disttask-ue4.engineName=UE4加速 | ||
disttask-ue4.paramConfig.worker_version.paramName=编译环境 | ||
disttask-ue4.paramConfig.worker_version.paramEnum.win2019-pure-drived=Windows通用环境 | ||
disttask-ue4.paramConfig.worker_version.paramEnum.macvm=Mac通用环境 | ||
disttask-ue4.paramConfig.worker_version.paramEnum.tlinux2.2-generic=TLinux2.2通用环境 | ||
disttask-ue4.paramConfig.queue_name=加速平台 | ||
|
||
distcc.desc=【旧版本】传统distcc方案, 适用于linux下的c/c++编译 | ||
distcc.engineName=distcc | ||
distcc.paramConfig.city.paramName=优先调度区域 | ||
distcc.paramConfig.city.paramEnum.K8S\://gd=深圳K8S集群(推荐) | ||
distcc.paramConfig.city.paramEnum.shenzhen=深圳/广州 | ||
distcc.paramConfig.city.paramEnum.shanghai=上海/南京 | ||
distcc.paramConfig.city.paramEnum.chengdu=成都/重庆 | ||
distcc.paramConfig.city.paramEnum.tianjin=北京/天津 | ||
distcc.paramConfig.gcc_version.paramName=编译器版本 | ||
distcc.paramConfig.ccache_enabled.paramName=是否启用Ccache | ||
|
||
displayFields.queue_name.fieldName=加速集群地区 | ||
displayFields.request_cpu.fieldName=加速资源 | ||
displayFields.worker_version.fieldName=Worker 版本 | ||
displayFields.client_version.fieldName=Client 版本 | ||
displayFields.client_ip.fieldName=发起机器 IP |
31 changes: 31 additions & 0 deletions
31
...common-turbo/common-turbo-util/src/main/kotlin/com/tencent/devops/common/util/I18NUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.tencent.devops.common.util | ||
|
||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.context.MessageSource | ||
import org.springframework.context.i18n.LocaleContextHolder | ||
import org.springframework.stereotype.Component | ||
import java.util.Locale | ||
|
||
@Component | ||
object I18NUtil { | ||
|
||
@JvmStatic | ||
lateinit var messageSource: MessageSource | ||
@Autowired set | ||
|
||
|
||
@JvmStatic | ||
fun getMessage(code: String): String { | ||
return getMessage(code, null) | ||
} | ||
|
||
@JvmStatic | ||
fun getMessage(code: String, args: Array<Any>?): String { | ||
return getMessage(code, args, LocaleContextHolder.getLocale()) | ||
} | ||
|
||
@JvmStatic | ||
fun getMessage(code: String, args: Array<Any>?, locale: Locale): String { | ||
return messageSource.getMessage(code, args, locale) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...-turbo-web/src/main/kotlin/com/tencent/devops/common/web/interceptor/LocaleInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.tencent.devops.common.web.interceptor | ||
|
||
import org.springframework.context.i18n.LocaleContextHolder | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.servlet.HandlerInterceptor | ||
import java.util.Locale | ||
import javax.servlet.http.HttpServletRequest | ||
import javax.servlet.http.HttpServletResponse | ||
|
||
@Component | ||
class LocaleInterceptor : HandlerInterceptor { | ||
|
||
override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean { | ||
val acceptLanguage = request.getHeader("Accept-Language") | ||
val parameterLocale = request.getParameter("locale") | ||
val locale = parseLocale(acceptLanguage, parameterLocale) | ||
LocaleContextHolder.setLocale(locale) | ||
|
||
return true | ||
} | ||
|
||
private fun parseLocale(acceptLanguage: String?, paramLocale: String?): Locale { | ||
if (!acceptLanguage.isNullOrBlank()) { | ||
val languageTag = acceptLanguage.split(",")[0].trim() | ||
return Locale.forLanguageTag(languageTag) | ||
} | ||
|
||
if (!paramLocale.isNullOrBlank()) { | ||
return genLocale(paramLocale) | ||
} | ||
|
||
return Locale.getDefault() | ||
} | ||
|
||
private fun genLocale(requestParameter: String): Locale { | ||
val splitArr = if (requestParameter.contains("-")) { | ||
requestParameter.split("-") | ||
} else { | ||
requestParameter.split("_") | ||
} | ||
return Locale(splitArr[0], splitArr[1]) | ||
} | ||
} |