Skip to content

Commit

Permalink
pref:插件国际化properties文件value值支持引入文件 #9366
Browse files Browse the repository at this point in the history
  • Loading branch information
yjieliang committed Nov 3, 2023
1 parent 7d16061 commit c884094
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ object TextReferenceFileAnalysisUtil {
result: MutableMap<String, String>,
text: String
): String {
val fileSeparator = File.separator
var content = text
// 替换资源路径
result.forEach {
val analysisPattern: Pattern = Pattern.compile("(\\\$\\{\\{indexFile\\(\"${it.key}\"\\)}})")
for (entry in result.entries) {
val key = entry.key
val value = entry.value.replace(fileSeparator, "\\$fileSeparator")
val analysisPattern: Pattern = Pattern.compile("(\\\$\\{\\{indexFile\\(\"$key\"\\)}})")
val analysisMatcher: Matcher = analysisPattern.matcher(content)
content = analysisMatcher.replaceFirst(
"![${it.key}](${it.value.replace(fileSeparator, "\\$fileSeparator")})"
)
while (analysisMatcher.find()) {
val match = analysisMatcher.group()
content = content.replace(match, "![${key}](${value})")
}
}
return content
}
Expand Down

0 comments on commit c884094

Please sign in to comment.