Skip to content

Commit be86ee9

Browse files
committed
fix: language tag parsing
1 parent 38a02c9 commit be86ee9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/CloudNetRestModule.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,14 @@ public final class CloudNetRestModule extends DriverModule {
7171
public static void loadTranslations(@NonNull I18n i18n) {
7272
var resourcePath = Path.of(ResourceResolver.resolveCodeSourceOfClass(CloudNetRestModule.class));
7373
FileUtil.openZipFile(resourcePath, fs -> {
74-
// get the language directory
7574
var langDir = fs.getPath("lang/");
7675
if (Files.notExists(langDir) || !Files.isDirectory(langDir)) {
7776
throw new IllegalStateException("lang/ must be an existing directory inside the jar to load");
7877
}
79-
// visit each file and register it as a language source
78+
8079
FileUtil.walkFileTree(langDir, ($, sub) -> {
81-
// try to load and register the language file
8280
try (var stream = Files.newInputStream(sub)) {
83-
var lang = sub.getFileName().toString().replace(".properties", "");
81+
var lang = sub.getFileName().toString().replace('_', '-').replace(".properties", "");
8482
i18n.registerProvider(Locale.forLanguageTag(lang), PropertiesTranslationProvider.fromProperties(stream));
8583
} catch (IOException exception) {
8684
LOGGER.error("Unable to open language file for reading @ {}", sub, exception);

0 commit comments

Comments
 (0)