diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-07-31 16:53:54 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-08-07 14:58:57 -0700 |
| commit | 933add6cd833bb6ba6682ad2b6eb478871415ff5 (patch) | |
| tree | 8cb5ee1feb0516c24ee270fcee5ed00d310aced8 /py/makeqstrdefs.py | |
| parent | 2029c4e87e3e71ada07c8be91fe6877edf4a606b (diff) | |
Support internationalisation.
Diffstat (limited to 'py/makeqstrdefs.py')
| -rw-r--r-- | py/makeqstrdefs.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index 4253c1147..06cf9078a 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -73,10 +73,11 @@ def qstr_unescape(qstr): return qstr def process_file(f): - re_line = re.compile(r"#[line]*\s\d+\s\"([^\"]+)\"") + re_line = re.compile(r"#[line]*\s(\d+)\s\"([^\"]+)\"") re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+') output = [] last_fname = None + lineno = 0 for line in f: if line.isspace(): continue @@ -84,7 +85,9 @@ def process_file(f): if line.startswith(('# ', '#line')): m = re_line.match(line) assert m is not None - fname = m.group(1) + #print(m.groups()) + lineno = int(m.group(1)) + fname = m.group(2) if not fname.endswith(".c"): continue if fname != last_fname: @@ -96,6 +99,9 @@ def process_file(f): name = match.replace('MP_QSTR_', '') if name not in QSTRING_BLACK_LIST: output.append('Q(' + qstr_unescape(name) + ')') + for match in re.findall(r'translate\(\"([^\"]+)\"\)', line): + output.append('TRANSLATE("' + match + '")') + lineno += 1 write_out(last_fname, output) return "" |
