diff options
Diffstat (limited to 'editor/translations/extract.py')
-rwxr-xr-x | editor/translations/extract.py | 29 |
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): |