Use correct charset on io operations
Always use the charset provided by the file
This commit is contained in:
parent
32c2eb20b4
commit
976458ac33
@ -44,7 +44,7 @@ public class JsonTranslatorIO implements TranslatorIO {
|
||||
try {
|
||||
for(VirtualFile file : files) {
|
||||
locales.add(file.getNameWithoutExtension());
|
||||
JsonObject tree = JsonParser.parseReader(new InputStreamReader(file.getInputStream())).getAsJsonObject();
|
||||
JsonObject tree = JsonParser.parseReader(new InputStreamReader(file.getInputStream(), file.getCharset())).getAsJsonObject();
|
||||
readTree(file.getNameWithoutExtension(), tree, nodes);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class JsonTranslatorIO implements TranslatorIO {
|
||||
String fullPath = directoryPath + "/" + locale + "." + FILE_EXTENSION;
|
||||
VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(fullPath));
|
||||
|
||||
file.setBinaryContent(gson.toJson(content).getBytes());
|
||||
file.setBinaryContent(gson.toJson(content).getBytes(file.getCharset()));
|
||||
}
|
||||
|
||||
// Successfully saved
|
||||
@ -133,8 +133,6 @@ public class JsonTranslatorIO implements TranslatorIO {
|
||||
Map<String, String> messages = leafNode.getValue();
|
||||
messages.put(locale, entry.getValue().getAsString());
|
||||
leafNode.setValue(messages);
|
||||
|
||||
System.out.println("updated key + " + key + "de locale: " + messages.get("locale-de"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class PropertiesTranslatorIO implements TranslatorIO {
|
||||
for (VirtualFile file : files) {
|
||||
locales.add(file.getNameWithoutExtension());
|
||||
Properties properties = new Properties();
|
||||
properties.load(new InputStreamReader(file.getInputStream()));;
|
||||
properties.load(new InputStreamReader(file.getInputStream(), file.getCharset()));;
|
||||
readProperties(file.getNameWithoutExtension(), properties, nodes);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class PropertiesTranslatorIO implements TranslatorIO {
|
||||
|
||||
ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||
properties.store(content, "I18n " + locale + " keys");
|
||||
file.setBinaryContent(content.toByteArray());
|
||||
file.setBinaryContent(content.toString().getBytes(file.getCharset()));
|
||||
}
|
||||
|
||||
// Successfully saved
|
||||
|
Loading…
x
Reference in New Issue
Block a user