summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-09-27 19:32:15 +0200
committerCarl Hetherington <cth@carlh.net>2020-09-27 19:33:09 +0200
commit627dfd9a5cdcce9e4122ef3041a38c3da2d3a120 (patch)
treea250e81f9d6b746bfbadb2428dbdea8c1ac1de6d /scripts
parentf3e69079eefa18407b110ff23df26f7711ebf7e5 (diff)
Load language tags from on-disk files rather than embedding them
into a .cc. The .cc method causes compile times (and memory requirements) increase enormously with some compilers.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/update-language-subtags15
1 files changed, 6 insertions, 9 deletions
diff --git a/scripts/update-language-subtags b/scripts/update-language-subtags
index 5990085e..979d8168 100755
--- a/scripts/update-language-subtags
+++ b/scripts/update-language-subtags
@@ -1,5 +1,6 @@
#!/usr/bin/python3
+import os
import urllib.request
block = {}
@@ -25,14 +26,10 @@ with urllib.request.urlopen('https://www.iana.org/assignments/language-subtag-re
if len(p) > 1:
block[p[0]] = p[1][1:]
-def escape(s):
- return s.replace('"', '\\"')
-
-with open('src/language_tag_lists.cc', 'w') as f:
- for k, v in lists.items():
- print("static LanguageTag::SubtagData const %s_list[] = {" % k, file=f)
+for k, v in lists.items():
+ with open(os.path.join('tags', k), 'w') as f:
+ print(len(v), file=f)
for e in v:
- print('\t{ "%s", "%s" },' % (escape(e[0]), escape(e[1])), file=f)
- print("};", file=f)
- print("", file=f)
+ print(e[0], file=f)
+ print(e[1], file=f)