import art.library.interop.serialization.Serialization;
|
import art.library.model.ModelConfiguration;
|
import java.io.File;
|
import java.nio.file.Files;
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.SortedSet;
|
import java.util.TreeSet;
|
|
public class Messages
|
{
|
|
private static Map<String, String> map = new HashMap<String, String>();
|
private static ModelConfiguration configuration = null;
|
private static String language = "pl-PL";
|
|
|
public static void main(String[] args) throws Exception
|
{
|
try
|
{
|
configuration = (ModelConfiguration) Serialization.deserialize(ModelConfiguration.class, new File("data/gddkia.kszrd.mediators.json"));
|
File file = new File("src");
|
System.out.println(file.getAbsolutePath());
|
messages(file);
|
|
SortedSet<String> keys = new TreeSet<>(map.keySet());
|
for (String key : keys)
|
{
|
String value = map.get(key);
|
System.out.println("\"" + key + "\" : \"" + value + "\",");
|
}
|
}
|
catch (Exception exception)
|
{
|
exception.printStackTrace();
|
}
|
}
|
|
|
private static void messages(File file) throws Exception
|
{
|
if (file.isDirectory() == true)
|
{
|
for (File child : file.listFiles())
|
{
|
messages(child);
|
}
|
}
|
else
|
{
|
find(file);
|
}
|
}
|
|
|
private static void find(File file) throws Exception
|
{
|
if (file.getName().endsWith("java"))
|
{
|
String content = new String(Files.readAllBytes(file.toPath()));
|
|
int index = content.indexOf("Model.getMessage");
|
|
while (index >= 0)
|
{
|
int index1 = content.indexOf("\"", index) + 1;
|
int index2 = content.indexOf("\"", index1);
|
String identifier = content.substring(index1, index2);
|
if (identifier.length() > 0)
|
{
|
if (configuration.existsMessage(language, identifier) == true)
|
{
|
String message = configuration.getMessage(language, identifier);
|
map.put(identifier, message);
|
}
|
else
|
{
|
map.put(identifier, "??????????");
|
}
|
}
|
index = content.indexOf("Model.getMessage", index2);
|
}
|
|
}
|
}
|
}
|