Skip to content

Commit

Permalink
pref:插件国际化properties文件value值支持引入文件 TencentBlueKing#9366
Browse files Browse the repository at this point in the history
  • Loading branch information
yjieliang committed Sep 20, 2023
1 parent 30b287a commit 43cecf3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,23 @@ class AtomDao : AtomBaseDao() {
}
}

fun updateAtomDescriptionByCode(
dslContext: DSLContext,
userId: String,
atomCode: String,
description: String,
version: String
) {
return with(TAtom.T_ATOM) {
dslContext.update(this)
.set(DESCRIPTION, description)
.set(UPDATE_TIME, LocalDateTime.now())
.set(MODIFIER, userId)
.where(ATOM_CODE.eq(atomCode).and(VERSION.eq(version)))
.execute()
}
}

/**
* 获取已安装的插件个数
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.tencent.devops.common.client.Client
import com.tencent.devops.common.service.config.CommonConfig
import com.tencent.devops.common.web.service.ServiceI18nMessageResource
import com.tencent.devops.common.web.utils.I18nUtil
import com.tencent.devops.store.dao.atom.AtomDao
import com.tencent.devops.store.pojo.common.KEY_RELEASE_INFO
import com.tencent.devops.store.service.common.StoreFileService
import com.tencent.devops.store.service.common.StoreFileService.Companion.BK_CI_PATH_REGEX
Expand Down Expand Up @@ -71,6 +72,9 @@ abstract class StoreI18nMessageServiceImpl : StoreI18nMessageService {
@Autowired
lateinit var storeFileService: StoreFileService

@Autowired
lateinit var atomDao: AtomDao

companion object {
private const val MESSAGE_NAME_TEMPLATE = "message_%s.properties"
private const val BATCH_HANDLE_NUM = 50
Expand Down Expand Up @@ -235,14 +239,26 @@ abstract class StoreI18nMessageServiceImpl : StoreI18nMessageService {
) ?: return@forEach
val description = fileProperties["$KEY_RELEASE_INFO.$KEY_DESCRIPTION"]?.toString()
if (!description.isNullOrBlank()) {
fileProperties["$KEY_RELEASE_INFO.$KEY_DESCRIPTION"] = getDescriptionI18nContent(
val descriptionStr = getDescriptionI18nContent(
userId = userId,
projectCode = projectCode,
fileDir = fileDir,
repositoryHashId = repositoryHashId,
content = description,
language = language
)
fileProperties["$KEY_RELEASE_INFO.$KEY_DESCRIPTION"] = descriptionStr
if (language == commonConfig.devopsDefaultLocaleLanguage) {
val atomCode = fileDir.substringBefore("/")
val version = fileDir.substringAfter("/")
atomDao.updateAtomDescriptionByCode(
dslContext = dslContext,
userId = userId,
atomCode = atomCode,
description = descriptionStr,
version = version
)
}
}
val i18nMessages = generateI18nMessages(
fieldLocaleInfos = fieldLocaleInfos,
Expand Down

0 comments on commit 43cecf3

Please sign in to comment.