ghy
Alejandro Acuña
2025-03-12 26319e4c5bfbee722c15b8e7ccca9b6127bb1cb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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);
            }
 
        }
    }
}