diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-04-01 11:04:20 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-04-01 11:35:22 +0800 |
commit | 2f20ff0ed6a9eae45b2c3045a2abd8deed032f89 (patch) | |
tree | 0b3c0bbae723089279c1b0342eb229456fd21d1a /editor/translations | |
parent | 340ad7d74869e71d88f6ce7dcb1cf20e924faed2 (diff) |
Extract theme property names for localization
Diffstat (limited to 'editor/translations')
-rwxr-xr-x | editor/translations/extract.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/editor/translations/extract.py b/editor/translations/extract.py index cb918c0092..bd32fc01c7 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -3,6 +3,7 @@ import enum import fnmatch import os +import os.path import re import shutil import subprocess @@ -128,6 +129,9 @@ message_patterns = { re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP, re.compile(r'#define WRTC_\w+ "(?P<message>[^"]+?)"'): ExtractType.PROPERTY_PATH, } +theme_property_patterns = { + re.compile(r'set_(constant|font|font_size|stylebox|color|icon)\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH, +} # See String::camelcase_to_underscore(). @@ -200,6 +204,10 @@ def process_file(f, fname): translator_comment = "" current_group = "" + patterns = message_patterns + if os.path.basename(fname) == "default_theme.cpp": + patterns = {**message_patterns, **theme_property_patterns} + while l: # Detect translator comments. @@ -217,7 +225,7 @@ def process_file(f, fname): translator_comment = translator_comment[:-1] # Remove extra \n at the end. if not reading_translator_comment: - for pattern, extract_type in message_patterns.items(): + for pattern, extract_type in patterns.items(): for m in pattern.finditer(l): location = os.path.relpath(fname).replace("\\", "/") if line_nb: |