mirror of
https://github.moeyy.xyz/https://github.com/GeWuYou/forgeboot
synced 2025-10-28 02:48:56 +08:00
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:
parent
42eadcece0
commit
b4c8b6036b
@ -36,6 +36,7 @@ allprojects {
|
|||||||
ext {
|
ext {
|
||||||
set(ProjectFlags.IS_ROOT_MODULE, false)
|
set(ProjectFlags.IS_ROOT_MODULE, false)
|
||||||
set(ProjectFlags.USE_SPRING_BOOT_BOM, false)
|
set(ProjectFlags.USE_SPRING_BOOT_BOM, false)
|
||||||
|
set(ProjectFlags.USE_CONFIGURATION_PROCESSOR, false)
|
||||||
}
|
}
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
if (project.getPropertyByBoolean(ProjectFlags.IS_ROOT_MODULE)) {
|
if (project.getPropertyByBoolean(ProjectFlags.IS_ROOT_MODULE)) {
|
||||||
@ -57,6 +58,11 @@ subprojects {
|
|||||||
implementation(platform(libs.springBootDependencies.bom))
|
implementation(platform(libs.springBootDependencies.bom))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(project.getPropertyByBoolean(ProjectFlags.USE_CONFIGURATION_PROCESSOR)){
|
||||||
|
dependencies {
|
||||||
|
annotationProcessor(libs.springBoot.configuration.processor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val libs = rootProject.libs
|
val libs = rootProject.libs
|
||||||
apply {
|
apply {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
object ProjectFlags {
|
object ProjectFlags {
|
||||||
const val IS_ROOT_MODULE = "isRootModule"
|
const val IS_ROOT_MODULE = "isRootModule"
|
||||||
const val USE_SPRING_BOOT_BOM = "useSpringBootBom"
|
const val USE_SPRING_BOOT_BOM = "useSpringBootBom"
|
||||||
|
const val USE_CONFIGURATION_PROCESSOR = "useConfigurationProcessor"
|
||||||
}
|
}
|
||||||
@ -1,3 +1,3 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
|
api(project(Modules.Core.EXTENSION))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
extra {
|
extra {
|
||||||
// 需要SpringBootBom
|
// 需要SpringBootBom
|
||||||
setProperty(ProjectFlags.USE_SPRING_BOOT_BOM, true)
|
setProperty(ProjectFlags.USE_SPRING_BOOT_BOM, true)
|
||||||
|
setProperty(ProjectFlags.USE_CONFIGURATION_PROCESSOR, true)
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(Modules.Core.EXTENSION))
|
implementation(project(Modules.Core.EXTENSION))
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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"
|
|
||||||
}
|
|
||||||
@ -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-web = { group = "org.springframework.boot", name = "spring-boot-starter-web" }
|
||||||
springBootStarter-webflux = { group = "org.springframework.boot", name = "spring-boot-starter-webflux" }
|
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" }
|
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
|
# Libraries can be bundled together for easier import
|
||||||
[bundles]
|
[bundles]
|
||||||
kotlinxEcosystem = ["kotlinxDatetime", "kotlinxSerialization", "kotlinxCoroutines-core"]
|
kotlinxEcosystem = ["kotlinxDatetime", "kotlinxSerialization", "kotlinxCoroutines-core"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user