feat(i18n): Add international support and optimize project configuration

- Added USE_CONFIGURATION_PROCESSOR project flag
- Add API dependency to Core.EXTENSION in forgeboot-core
- Rename the I18nProperties file and convert it to Java class
- Update forgeboot-i18n dependency and add configuration processor
- Add spring-boot-configuration-processor dependency in libs.versions.toml
- Update root project configuration, support configuration processor
This commit is contained in:
gewuyou 2025-04-30 12:52:45 +08:00
parent 42eadcece0
commit b4c8b6036b
7 changed files with 60 additions and 28 deletions

View File

@ -36,6 +36,7 @@ allprojects {
ext {
set(ProjectFlags.IS_ROOT_MODULE, false)
set(ProjectFlags.USE_SPRING_BOOT_BOM, false)
set(ProjectFlags.USE_CONFIGURATION_PROCESSOR, false)
}
afterEvaluate {
if (project.getPropertyByBoolean(ProjectFlags.IS_ROOT_MODULE)) {
@ -57,6 +58,11 @@ subprojects {
implementation(platform(libs.springBootDependencies.bom))
}
}
if(project.getPropertyByBoolean(ProjectFlags.USE_CONFIGURATION_PROCESSOR)){
dependencies {
annotationProcessor(libs.springBoot.configuration.processor)
}
}
}
val libs = rootProject.libs
apply {

View File

@ -1,4 +1,5 @@
object ProjectFlags {
const val IS_ROOT_MODULE = "isRootModule"
const val USE_SPRING_BOOT_BOM = "useSpringBootBom"
const val USE_CONFIGURATION_PROCESSOR = "useConfigurationProcessor"
}

View File

@ -1,3 +1,3 @@
dependencies {
api(project(Modules.Core.EXTENSION))
}

View File

@ -1,6 +1,7 @@
extra {
// 需要SpringBootBom
setProperty(ProjectFlags.USE_SPRING_BOOT_BOM, true)
setProperty(ProjectFlags.USE_CONFIGURATION_PROCESSOR, true)
}
dependencies {
implementation(project(Modules.Core.EXTENSION))

View File

@ -0,0 +1,50 @@
package com.gewuyou.forgeboot.i18n.config.entity;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* i18n属性
*
* @author gewuyou
* @since 2025-02-18 23:59:57
*/
@ConfigurationProperties(prefix = "base-forge.i18n")
public class I18nProperties {
/**
* 默认语言
*/
private String defaultLocale = "zh_CN";
/**
* 语言请求参数名
*/
private String langRequestParameter = "lang";
/**
* 语言文件路径
*/
private String wildPathForLanguageFiles = "classpath*:i18n/**/messages";
public String getDefaultLocale() {
return defaultLocale;
}
public void setDefaultLocale(String defaultLocale) {
this.defaultLocale = defaultLocale;
}
public String getLangRequestParameter() {
return langRequestParameter;
}
public void setLangRequestParameter(String langRequestParameter) {
this.langRequestParameter = langRequestParameter;
}
public String getWildPathForLanguageFiles() {
return wildPathForLanguageFiles;
}
public void setWildPathForLanguageFiles(String wildPathForLanguageFiles) {
this.wildPathForLanguageFiles = wildPathForLanguageFiles;
}
}

View File

@ -1,26 +0,0 @@
package com.gewuyou.forgeboot.i18n.config.entity
import org.springframework.boot.context.properties.ConfigurationProperties
/**
* i18n属性
*
* @author gewuyou
* @since 2025-02-18 23:59:57
*/
@ConfigurationProperties(prefix = "base-forge.i18n")
class I18nProperties {
/**
* 默认语言
*/
var defaultLocale = "zh_CN"
/**
* 语言请求参数名
*/
var langRequestParameter = "lang"
/**
* 语言文件路径
*/
var wildPathForLanguageFiles = "classpath*:i18n/**/messages"
}

View File

@ -26,7 +26,7 @@ springBootStarter-aop = { group = "org.springframework.boot", name = "spring-boo
springBootStarter-web = { group = "org.springframework.boot", name = "spring-boot-starter-web" }
springBootStarter-webflux = { group = "org.springframework.boot", name = "spring-boot-starter-webflux" }
springBootDependencies-bom = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "spring-boot-version" }
springBoot-configuration-processor = { group = "org.springframework.boot", name = "spring-boot-configuration-processor", version.ref = "spring-boot-version" }
# Libraries can be bundled together for easier import
[bundles]
kotlinxEcosystem = ["kotlinxDatetime", "kotlinxSerialization", "kotlinxCoroutines-core"]