(string[] args)
| 31 | public Dictionary<string, string> complete = new(); |
| 32 | } |
| 33 | static void Main(string[] args) { |
| 34 | |
| 35 | var path = GetCurPath(); |
| 36 | |
| 37 | // получаем актуальные данные |
| 38 | var english = GetLocsFromFolder(Path.Combine(path, "..", "src")); |
| 39 | |
| 40 | Dictionary<string, Info> simpleLoc = new(); |
| 41 | Info get(string lang) { |
| 42 | if (!simpleLoc.TryGetValue(lang, out var dict)) { dict = new(); simpleLoc.Add(lang, dict); } |
| 43 | return dict; |
| 44 | } |
| 45 | |
| 46 | foreach (var f_ in Directory.GetFiles(path, "*.json")) { |
| 47 | |
| 48 | var curDict = new Dictionary<string, string>(); |
| 49 | try { |
| 50 | using var stream = File.OpenRead(f_); |
| 51 | curDict = JsonSerializer.Deserialize<Dictionary<string, string>>(stream); |
| 52 | } catch (Exception) { } |
| 53 | var name = Path.GetFileName(f_).Trim('_'); |
| 54 | name = name[..name.IndexOf('.')]; |
| 55 | var info = get(name); |
| 56 | foreach (var item in curDict) { |
| 57 | if (!string.IsNullOrEmpty(item.Value)) { |
| 58 | if (!english.Contains(item.Key)) continue; |
| 59 | info.complete[item.Key] = item.Value; |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | HashSet<string> rewriten = new(); |
| 65 | |
| 66 | var opt = new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; |
| 67 | |
| 68 | int to_translate = 0; |
| 69 | foreach (var item in simpleLoc) { |
| 70 | var name = item.Key; |
| 71 | var info = item.Value; |
| 72 | var file = Path.Combine(path, name + ".json"); |
| 73 | File.WriteAllText(file, JsonSerializer.Serialize(info.complete, opt)); |
| 74 | rewriten.Add(file); |
| 75 | |
| 76 | int curI = -1; |
| 77 | foreach (var chunk in english.Where(x => !info.complete.ContainsKey(x)).Chunk(40)){ |
| 78 | to_translate += chunk.Count(); |
| 79 | curI++; |
| 80 | file = Path.Combine(path, name + $".{curI}.json"); |
| 81 | File.WriteAllText(file, JsonSerializer.Serialize(chunk.ToDictionary(x => x, x => ""), opt)); |
| 82 | rewriten.Add(file); |
| 83 | } |
| 84 | |
| 85 | var header = LocalizationGenerator.GenerateCppFile(name, info.complete); |
| 86 | File.WriteAllText(Path.Combine(path, name + ".h"), header); |
| 87 | |
| 88 | } |
| 89 | |
| 90 | foreach (var f_ in Directory.GetFiles(path, "*.json")) { |
nothing calls this directly
no test coverage detected