mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-08 07:25:54 +01:00
misc/ already hosts optional supplemental modules (cpp/imgui_stdlib, freetype/, fonts/). i18n fits the same pattern: opt-in, not part of the core library. Update all include paths, Makefile, Xcode project and README accordingly.
26 lines
799 B
Python
26 lines
799 B
Python
#!/usr/bin/env python3
|
||
"""
|
||
用法:python3 extract_strings.py imgui_demo.cpp 302 737
|
||
输出 zh_CN.cpp 条目骨架(key=英文,value 留空供人工翻译)
|
||
"""
|
||
import sys, re
|
||
|
||
def extract(path, start, end):
|
||
with open(path) as f:
|
||
lines = f.readlines()
|
||
chunk = ''.join(lines[start-1:end-1])
|
||
strings = re.findall(r'"([^"\n]{2,80})"', chunk)
|
||
seen = set()
|
||
results = []
|
||
skip = re.compile(r'^(##|###|%[0-9.]*[dfsx]$|[0-9.]+$)')
|
||
for s in strings:
|
||
if s in seen or skip.match(s): continue
|
||
seen.add(s)
|
||
results.append(s)
|
||
for s in results:
|
||
escaped = s.replace('\\', '\\\\').replace('"', '\\"')
|
||
print(f' {{"{escaped}", ""}},')
|
||
|
||
if __name__ == '__main__':
|
||
extract(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
|