Fix dependencies when extracting required charset from po file

This commit is contained in:
Guillaume Meunier
2024-06-22 18:22:10 +02:00
parent 9b88b205bb
commit d17a511cfc
2 changed files with 35 additions and 18 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env python
import sys
import os.path
print(
"""// Generated file, do not edit
#include <map>
#include <string>
#include <vector>
std::map<std::string, std::vector<int>> glyph_set_per_language = {""")
for po_file in sys.argv[1:]:
lang = os.path.basename(os.path.dirname(po_file))
with open(po_file) as f:
charset = sorted(set(f.read()))
# Basic Latin and Latin-1 Supplement are always included
charset = ', '.join([str(ord(c)) for c in charset if ord(c) > 255])
print("\t{{ \"{}\", {{{}}}}},".format(lang, charset))
print("};")