Skip to content

Commit 9336cbb

Browse files
dragonpooludomikula
authored andcommitted
make en_US as a default if lang is empty.
1 parent 62b795b commit 9336cbb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/configuration/CustomWebFluxConfiguration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import lombok.RequiredArgsConstructor;
5+
import org.apache.commons.lang3.StringUtils;
56
import org.lowcoder.api.framework.plugin.endpoint.ReloadableRouterFunctionMapping;
67
import org.lowcoder.sdk.util.JsonUtils;
78
import org.springframework.beans.factory.annotation.Value;
@@ -55,14 +56,16 @@ public LocaleContextResolver localeContextResolver() {
5556
return new LocaleContextResolver() {
5657
@Override
5758
public LocaleContext resolveLocaleContext(ServerWebExchange exchange) {
58-
List<String> language = exchange.getRequest().getQueryParams().getOrDefault("lang", List.of("en_US"));
59+
String defaultLocaleStr = "en_US";
60+
List<String> language = exchange.getRequest().getQueryParams().getOrDefault("lang", List.of(defaultLocaleStr));
5961
String localeStr = language.get(0);
6062
String[] parts = localeStr.split("_");
6163
if(parts.length == 2) {
6264
Locale locale = new Locale(parts[0], parts[1]);
6365
return new SimpleLocaleContext(locale);
6466
} else {
65-
Locale locale = new Locale(parts[0]);
67+
String safeLocaleStr = StringUtils.defaultIfBlank(parts[0], defaultLocaleStr);
68+
Locale locale = new Locale(safeLocaleStr);
6669
return new SimpleLocaleContext(locale);
6770
}
6871
}

0 commit comments

Comments
 (0)