Skip to content

Commit

Permalink
Merge pull request #185 from gbourant/i18n
Browse files Browse the repository at this point in the history
merge i18n messages bundles
  • Loading branch information
FroMage authored Jan 3, 2024
2 parents b35a879 + bcc62f2 commit a1c58da
Showing 1 changed file with 20 additions and 4 deletions.
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);

}

}

0 comments on commit a1c58da

Please sign in to comment.