Skip to content

Commit

Permalink
fix(locale): load translations with utf-8
Browse files Browse the repository at this point in the history
Signed-off-by: SettingDust <[email protected]>
  • Loading branch information
SettingDust committed Jun 6, 2022
1 parent f0db822 commit b6b5aff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/team/ebi/epicbanitem/EBITranslation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
Expand Down Expand Up @@ -75,7 +77,7 @@ private void loadExternal() throws IOException {
.forEach(it -> {
try {
final var properties = new Properties();
properties.load(Files.newInputStream(it));
properties.load(new InputStreamReader(Files.newInputStream(it), StandardCharsets.UTF_8));
externalProperties.put(it, properties);
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -94,7 +96,7 @@ public void removeExternal(String key) {
public void saveExternal() {
externalProperties.forEach((path, properties) -> {
try {
properties.store(Files.newOutputStream(path), null);
properties.store(new OutputStreamWriter(Files.newOutputStream(path), StandardCharsets.UTF_8), null);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -116,7 +118,8 @@ public void loadMessages() {
final var name = path.name();
final var resource = contents.requireResource(PackType.server(), path);
final var locale = name.substring(9, name.lastIndexOf(".properties"));
var bundle = new PropertyResourceBundle(new InputStreamReader(resource.inputStream()));
var bundle = new PropertyResourceBundle(
new InputStreamReader(resource.inputStream(), StandardCharsets.UTF_8));
final var external = messagesDir.resolve(name);
if (Files.notExists(external)) Files.createFile(external);
try (final var reader = Files.newBufferedReader(external)) {
Expand Down

0 comments on commit b6b5aff

Please sign in to comment.