Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge i18n messages bundles #185

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -42,13 +44,27 @@ void addLanguageBundle(String language, String bundlePath) {
if (cl == null) {
cl = RenardeConfig.class.getClassLoader();
}
try (Reader reader = new BufferedReader(
new InputStreamReader(cl.getResourceAsStream(bundlePath), StandardCharsets.UTF_8))) {
bundle.load(reader);
try {
Enumeration<URL> resources = cl.getResources(bundlePath);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
try (Reader reader = new BufferedReader(
new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
bundle.load(reader);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Properties properties = bundles.get(language);
if (properties == null) {
bundles.put(language, bundle);
} else {
properties.putAll(bundle);
}
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
bundles.put(language, bundle);

}

}