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后台信息国际化-调整i18n工具类 TencentBlueKing#86
- Loading branch information
Showing
3 changed files
with
5 additions
and
13 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
1 change: 1 addition & 0 deletions
1
src/backend/turbo/common-turbo/common-turbo-web/build.gradle.kts
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
15 changes: 3 additions & 12 deletions
15
...om/tencent/devops/common/util/I18NUtil.kt → ...ncent/devops/common/web/utils/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 |
---|---|---|
@@ -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) | ||
} | ||
} |