mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Try with resources
This commit is contained in:
1 file changed
+22
-20
@@ -141,32 +141,34 @@ public final class CarbonMessageSource implements IMessageSource<Audience, Strin
|
||||
}
|
||||
}));
|
||||
|
||||
Files.walk(localeDirectory).filter(Files::isRegularFile).forEach(path -> {
|
||||
final String localeString = path.getFileName().toString().substring("messages-".length()).replace(".properties", "");
|
||||
final @Nullable Locale locale = Translator.parseLocale(localeString.replace("nb_NO", "no_NO"));
|
||||
try (final Stream<Path> paths = Files.walk(localeDirectory)) {
|
||||
paths.filter(Files::isRegularFile).forEach(path -> {
|
||||
final String localeString = path.getFileName().toString().substring("messages-".length()).replace(".properties", "");
|
||||
final @Nullable Locale locale = Translator.parseLocale(localeString.replace("nb_NO", "no_NO"));
|
||||
|
||||
if (locale == null) {
|
||||
this.logger.warn("Unknown locale '{}'?", localeString);
|
||||
return;
|
||||
}
|
||||
if (locale == null) {
|
||||
this.logger.warn("Unknown locale '{}'?", localeString);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.locales.containsKey(locale)) {
|
||||
return;
|
||||
}
|
||||
if (this.locales.containsKey(locale)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.info("Found locale {} ({}) in: {}", locale.getDisplayName(), locale, path);
|
||||
this.logger.info("Found locale {} ({}) in: {}", locale.getDisplayName(), locale, path);
|
||||
|
||||
final Properties properties = new Properties();
|
||||
final Properties properties = new Properties();
|
||||
|
||||
try {
|
||||
this.loadProperties(properties, localeDirectory, path);
|
||||
this.locales.put(locale, properties);
|
||||
try {
|
||||
this.loadProperties(properties, localeDirectory, path);
|
||||
this.locales.put(locale, properties);
|
||||
|
||||
this.logger.info("Successfully loaded locale {} ({})", locale.getDisplayName(), locale);
|
||||
} catch (final IOException ex) {
|
||||
this.logger.warn("Unable to load locale {} ({}) from source: {}", locale.getDisplayName(), locale, path, ex);
|
||||
}
|
||||
});
|
||||
this.logger.info("Successfully loaded locale {} ({})", locale.getDisplayName(), locale);
|
||||
} catch (final IOException ex) {
|
||||
this.logger.warn("Unable to load locale {} ({}) from source: {}", locale.getDisplayName(), locale, path, ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user