summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2022-03-20 20:21:00 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2022-03-20 20:21:00 +0800
commit46f5cd65a1a4b40e8cb204d3cd421d95ac527119 (patch)
tree79ff16071f7625dda47381bde1324b72695c64b8 /editor
parent5901d9145822bd068078441f4e96377d49018ed9 (diff)
More editor `extract.py` improvements and fixes
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_property_name_processor.cpp20
-rwxr-xr-xeditor/translations/extract.py25
2 files changed, 31 insertions, 14 deletions
diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp
index 49f2f21095..f55b2b61c8 100644
--- a/editor/editor_property_name_processor.cpp
+++ b/editor/editor_property_name_processor.cpp
@@ -83,6 +83,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["aabb"] = "AABB";
capitalize_string_remaps["adb"] = "ADB";
capitalize_string_remaps["ao"] = "AO";
+ capitalize_string_remaps["apk"] = "APK";
capitalize_string_remaps["arvr"] = "ARVR";
capitalize_string_remaps["bg"] = "BG";
capitalize_string_remaps["bp"] = "BP";
@@ -119,15 +120,21 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["hsv"] = "HSV";
capitalize_string_remaps["http"] = "HTTP";
capitalize_string_remaps["id"] = "ID";
- capitalize_string_remaps["ik"] = "IK";
capitalize_string_remaps["igd"] = "IGD";
+ capitalize_string_remaps["ik"] = "IK";
+ capitalize_string_remaps["image@2x"] = "Image @2x";
+ capitalize_string_remaps["image@3x"] = "Image @3x";
capitalize_string_remaps["ios"] = "iOS";
capitalize_string_remaps["iod"] = "IOD";
capitalize_string_remaps["ip"] = "IP";
+ capitalize_string_remaps["ipad"] = "iPad";
+ capitalize_string_remaps["iphone"] = "iPhone";
capitalize_string_remaps["ipv6"] = "IPv6";
+ capitalize_string_remaps["jit"] = "JIT";
capitalize_string_remaps["k1"] = "K1";
capitalize_string_remaps["k2"] = "K2";
capitalize_string_remaps["kb"] = "(KB)"; // Unit.
+ capitalize_string_remaps["ldr"] = "LDR";
capitalize_string_remaps["lod"] = "LOD";
capitalize_string_remaps["lowpass"] = "Low-pass";
capitalize_string_remaps["macos"] = "macOS";
@@ -137,13 +144,16 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
//capitalize_string_remaps["msec"] = "(msec)"; // Unit.
capitalize_string_remaps["msaa"] = "MSAA";
capitalize_string_remaps["normalmap"] = "Normal Map";
+ capitalize_string_remaps["ok"] = "OK";
capitalize_string_remaps["opengl"] = "OpenGL";
capitalize_string_remaps["opentype"] = "OpenType";
capitalize_string_remaps["openxr"] = "OpenXR";
+ capitalize_string_remaps["pck"] = "PCK";
capitalize_string_remaps["png"] = "PNG";
capitalize_string_remaps["po2"] = "(Power of 2)"; // Unit.
capitalize_string_remaps["pvs"] = "PVS";
capitalize_string_remaps["pvrtc"] = "PVRTC";
+ capitalize_string_remaps["rgb"] = "RGB";
capitalize_string_remaps["rid"] = "RID";
capitalize_string_remaps["rmb"] = "RMB";
capitalize_string_remaps["rpc"] = "RPC";
@@ -152,18 +162,21 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["sdfgi"] = "SDFGI";
capitalize_string_remaps["sdk"] = "SDK";
capitalize_string_remaps["sec"] = "(sec)"; // Unit.
+ capitalize_string_remaps["srgb"] = "sRGB";
capitalize_string_remaps["ssao"] = "SSAO";
capitalize_string_remaps["ssh"] = "SSH";
capitalize_string_remaps["ssil"] = "SSIL";
capitalize_string_remaps["ssl"] = "SSL";
capitalize_string_remaps["stderr"] = "stderr";
capitalize_string_remaps["stdout"] = "stdout";
+ capitalize_string_remaps["svg"] = "SVG";
capitalize_string_remaps["tcp"] = "TCP";
capitalize_string_remaps["ui"] = "UI";
capitalize_string_remaps["url"] = "URL";
capitalize_string_remaps["urls"] = "URLs";
- capitalize_string_remaps["us"] = "(µs)"; // Unit.
- capitalize_string_remaps["usec"] = "(µsec)"; // Unit.
+ capitalize_string_remaps["us"] = String::utf8("(µs)"); // Unit.
+ capitalize_string_remaps["usec"] = String::utf8("(µsec)"); // Unit.
+ capitalize_string_remaps["uuid"] = "UUID";
capitalize_string_remaps["uv"] = "UV";
capitalize_string_remaps["uv1"] = "UV1";
capitalize_string_remaps["uv2"] = "UV2";
@@ -174,6 +187,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["webp"] = "WebP";
capitalize_string_remaps["webrtc"] = "WebRTC";
capitalize_string_remaps["websocket"] = "WebSocket";
+ capitalize_string_remaps["wifi"] = "Wi-Fi";
capitalize_string_remaps["xr"] = "XR";
capitalize_string_remaps["xy"] = "XY";
capitalize_string_remaps["xz"] = "XZ";
diff --git a/editor/translations/extract.py b/editor/translations/extract.py
index dd86bd1c1f..8737eb5204 100755
--- a/editor/translations/extract.py
+++ b/editor/translations/extract.py
@@ -34,12 +34,12 @@ matches.sort()
remaps = {}
-remap_re = re.compile(r'capitalize_string_remaps\["(.+)"\] = "(.+)";')
+remap_re = re.compile(r'^\t*capitalize_string_remaps\["(?P<from>.+)"\] = (String::utf8\()?"(?P<to>.+)"')
with open("editor/editor_property_name_processor.cpp") as f:
for line in f:
m = remap_re.search(line)
if m:
- remaps[m.group(1)] = m.group(2)
+ remaps[m.group("from")] = m.group("to")
unique_str = []
@@ -70,22 +70,25 @@ class ExtractType(enum.IntEnum):
GROUP = 3
-# Regex "(?P<name>(?:[^"\\]|\\.)*)" creates a group named `name` that matches a string.
+# Regex "(?P<name>([^"\\]|\\.)*)" creates a group named `name` that matches a string.
message_patterns = {
- re.compile(r'RTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
- re.compile(r'TTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
- re.compile(r'TTRC\("(?P<message>(?:[^"\\]|\\.)*)"\)'): ExtractType.TEXT,
+ re.compile(r'RTR\("(?P<message>([^"\\]|\\.)*)"(, "(?P<context>([^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
+ re.compile(r'TTR\("(?P<message>([^"\\]|\\.)*)"(, "(?P<context>([^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
+ re.compile(r'TTRC\("(?P<message>([^"\\]|\\.)*)"\)'): ExtractType.TEXT,
re.compile(
- r'TTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
+ r'TTRN\("(?P<message>([^"\\]|\\.)*)", "(?P<plural_message>([^"\\]|\\.)*)",[^,)]+?(, "(?P<context>([^"\\]|\\.)*)")?\)'
): ExtractType.TEXT,
re.compile(
- r'RTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
+ r'RTRN\("(?P<message>([^"\\]|\\.)*)", "(?P<plural_message>([^"\\]|\\.)*)",[^,)]+?(, "(?P<context>([^"\\]|\\.)*)")?\)'
): ExtractType.TEXT,
re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
- re.compile(r'GLOBAL_DEF(?:_RST)?\("(?P<message>[^".]+?)",'): ExtractType.PROPERTY_PATH,
- re.compile(r'EDITOR_DEF(?:_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
+ re.compile(r'GLOBAL_DEF(_RST)?(_NOVAL)?\("(?P<message>[^".]+?)",'): ExtractType.PROPERTY_PATH,
+ re.compile(r'EDITOR_DEF(_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
re.compile(
- r'ADD_PROPERTY\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]'
+ r'(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]'
+ ): ExtractType.PROPERTY_PATH,
+ re.compile(
+ r"(?!#define )LIMPL_PROPERTY(_RANGE)?\(Variant::[_A-Z0-9]+, (?P<message>[^,]+?),"
): ExtractType.PROPERTY_PATH,
re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP,
}