summaryrefslogtreecommitdiff
path: root/editor/translations
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2022-03-18 00:27:20 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2022-03-18 00:31:13 +0800
commite64cd21f6fbe738a200a160d2a5f57597d536cbc (patch)
tree869a41e20b1c5b67f1a43c976dd8d5ceaeb7d902 /editor/translations
parent5d806b435bdfb6669435f1a28589f847be5ff807 (diff)
Remap property path based on path substrings
Also added captialization caching.
Diffstat (limited to 'editor/translations')
-rwxr-xr-xeditor/translations/extract.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/editor/translations/extract.py b/editor/translations/extract.py
index 65d1341e9e..5f68d7702e 100755
--- a/editor/translations/extract.py
+++ b/editor/translations/extract.py
@@ -87,17 +87,24 @@ capitalize_re = re.compile(r"(?<=\D)(?=\d)|(?<=\d)(?=\D([a-z]|\d))")
def _process_editor_string(name):
- # See String::capitalize().
- # fmt: off
- capitalized = " ".join(
- part.title()
- for part in capitalize_re.sub("_", name).replace("_", " ").split()
- )
- # fmt: on
- # See EditorStringProcessor::process_string().
- for key, value in remaps.items():
- capitalized = capitalized.replace(key, value)
- return capitalized
+ # See EditorPropertyNameProcessor::process_string().
+ capitalized_parts = []
+ for segment in name.split("_"):
+ if not segment:
+ continue
+ remapped = remaps.get(segment)
+ if remapped:
+ capitalized_parts.append(remapped)
+ else:
+ # See String::capitalize().
+ # fmt: off
+ capitalized_parts.append(" ".join(
+ part.title()
+ for part in capitalize_re.sub("_", segment).replace("_", " ").split()
+ ))
+ # fmt: on
+
+ return " ".join(capitalized_parts)
def _write_message(msgctx, msg, msg_plural, location):