Skip to content

Commit

Permalink
feat: turbo后台信息国际化-调整i18n工具类 TencentBlueKing#86
Browse files Browse the repository at this point in the history
  • Loading branch information
eazence committed Jun 28, 2023
1 parent 476eaf5 commit ae5dd5f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.benmanes.caffeine.cache.Caffeine
import com.tencent.devops.common.api.exception.TurboException
import com.tencent.devops.common.api.exception.code.TURBO_PARAM_INVALID
import com.tencent.devops.common.db.PageUtils
import com.tencent.devops.common.util.I18NUtil
import com.tencent.devops.common.web.utils.I18NUtil
import com.tencent.devops.common.util.enums.ConfigParamType
import com.tencent.devops.turbo.dao.mongotemplate.TurboEngineConfigDao
import com.tencent.devops.turbo.dao.repository.TurboEngineConfigRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dependencies {
api(project(":common-turbo:common-turbo-api"))
api(project(":common-turbo:common-turbo-util"))
api(project(":common-turbo:common-turbo-service"))
api("com.tencent.devops:devops-boot-starter-web")
api("com.github.ulisesbocchio:jasypt-spring-boot-starter")
api("org.springframework.boot:spring-boot-starter-amqp")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
package com.tencent.devops.common.util
package com.tencent.devops.common.web.utils

import org.springframework.beans.factory.annotation.Autowired
import com.tencent.devops.common.service.utils.SpringContextUtil
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 {
val messageSource = SpringContextUtil.getBean(MessageSource::class.java)
return messageSource.getMessage(code, args, locale)
}
}

0 comments on commit ae5dd5f

Please sign in to comment.