diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/SystemParameterController.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/SystemParameterController.java index 7ff2a4f83d..81bce2125e 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/SystemParameterController.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/SystemParameterController.java @@ -7,23 +7,27 @@ import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogModule; import io.metersphere.commons.constants.ParamConstants; import io.metersphere.commons.constants.PermissionConstants; -import io.metersphere.request.HeaderRequest; +import io.metersphere.commons.user.SessionUser; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.ldap.domain.LdapInfo; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.notice.domain.MailInfo; +import io.metersphere.request.HeaderRequest; import io.metersphere.service.BaseUserService; import io.metersphere.service.SystemParameterService; +import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; import java.time.Duration; import java.util.HashMap; import java.util.List; +import java.util.Optional; @RestController @RequestMapping(value = "/system") @@ -145,8 +149,13 @@ public class SystemParameterController { @GetMapping(value = "/default-locale") public String defaultLocale() { - return defaultLocale; + SessionUser user = SessionUtils.getUser(); + String language = Optional.ofNullable(user) + .map(SessionUser::getLanguage) + .filter(StringUtils::isNotBlank) + .orElse(defaultLocale); + + return language.replace("_", "-"); } - }