Improves editor property name extraction
This commit is contained in:
parent
70eb95c30c
commit
4d73899352
4 changed files with 68 additions and 21 deletions
|
@ -170,9 +170,7 @@ EditorAbout::EditorAbout() {
|
||||||
dev_sections.push_back(TTR("Project Founders"));
|
dev_sections.push_back(TTR("Project Founders"));
|
||||||
dev_sections.push_back(TTR("Lead Developer"));
|
dev_sections.push_back(TTR("Lead Developer"));
|
||||||
// TRANSLATORS: This refers to a job title.
|
// TRANSLATORS: This refers to a job title.
|
||||||
// The trailing space is used to distinguish with the project list application,
|
dev_sections.push_back(TTR("Project Manager", "Job Title"));
|
||||||
// you do not have to keep it in your translation.
|
|
||||||
dev_sections.push_back(TTR("Project Manager "));
|
|
||||||
dev_sections.push_back(TTR("Developers"));
|
dev_sections.push_back(TTR("Developers"));
|
||||||
const char *const *dev_src[] = { AUTHORS_FOUNDERS, AUTHORS_LEAD_DEVELOPERS,
|
const char *const *dev_src[] = { AUTHORS_FOUNDERS, AUTHORS_LEAD_DEVELOPERS,
|
||||||
AUTHORS_PROJECT_MANAGERS, AUTHORS_DEVELOPERS };
|
AUTHORS_PROJECT_MANAGERS, AUTHORS_DEVELOPERS };
|
||||||
|
|
|
@ -83,15 +83,23 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
|
||||||
capitalize_string_remaps["aabb"] = "AABB";
|
capitalize_string_remaps["aabb"] = "AABB";
|
||||||
capitalize_string_remaps["adb"] = "ADB";
|
capitalize_string_remaps["adb"] = "ADB";
|
||||||
capitalize_string_remaps["ao"] = "AO";
|
capitalize_string_remaps["ao"] = "AO";
|
||||||
|
capitalize_string_remaps["arvr"] = "ARVR";
|
||||||
|
capitalize_string_remaps["bg"] = "BG";
|
||||||
|
capitalize_string_remaps["bp"] = "BP";
|
||||||
|
capitalize_string_remaps["bpc"] = "BPC";
|
||||||
capitalize_string_remaps["bptc"] = "BPTC";
|
capitalize_string_remaps["bptc"] = "BPTC";
|
||||||
capitalize_string_remaps["bvh"] = "BVH";
|
capitalize_string_remaps["bvh"] = "BVH";
|
||||||
|
capitalize_string_remaps["ca"] = "CA";
|
||||||
|
capitalize_string_remaps["cd"] = "CD";
|
||||||
capitalize_string_remaps["cpu"] = "CPU";
|
capitalize_string_remaps["cpu"] = "CPU";
|
||||||
capitalize_string_remaps["csg"] = "CSG";
|
capitalize_string_remaps["csg"] = "CSG";
|
||||||
capitalize_string_remaps["db"] = "dB";
|
capitalize_string_remaps["db"] = "dB";
|
||||||
capitalize_string_remaps["dof"] = "DoF";
|
capitalize_string_remaps["dof"] = "DoF";
|
||||||
capitalize_string_remaps["dpi"] = "DPI";
|
capitalize_string_remaps["dpi"] = "DPI";
|
||||||
|
capitalize_string_remaps["dtls"] = "DTLS";
|
||||||
capitalize_string_remaps["etc"] = "ETC";
|
capitalize_string_remaps["etc"] = "ETC";
|
||||||
capitalize_string_remaps["etc2"] = "ETC2";
|
capitalize_string_remaps["etc2"] = "ETC2";
|
||||||
|
capitalize_string_remaps["fft"] = "FFT";
|
||||||
capitalize_string_remaps["fov"] = "FOV";
|
capitalize_string_remaps["fov"] = "FOV";
|
||||||
capitalize_string_remaps["fps"] = "FPS";
|
capitalize_string_remaps["fps"] = "FPS";
|
||||||
capitalize_string_remaps["fs"] = "FS";
|
capitalize_string_remaps["fs"] = "FS";
|
||||||
|
@ -100,29 +108,50 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
|
||||||
capitalize_string_remaps["gdscript"] = "GDScript";
|
capitalize_string_remaps["gdscript"] = "GDScript";
|
||||||
capitalize_string_remaps["ggx"] = "GGX";
|
capitalize_string_remaps["ggx"] = "GGX";
|
||||||
capitalize_string_remaps["gi"] = "GI";
|
capitalize_string_remaps["gi"] = "GI";
|
||||||
|
capitalize_string_remaps["glb"] = "GLB";
|
||||||
capitalize_string_remaps["gles2"] = "GLES2";
|
capitalize_string_remaps["gles2"] = "GLES2";
|
||||||
capitalize_string_remaps["gles3"] = "GLES3";
|
capitalize_string_remaps["gles3"] = "GLES3";
|
||||||
capitalize_string_remaps["gpu"] = "GPU";
|
capitalize_string_remaps["gpu"] = "GPU";
|
||||||
capitalize_string_remaps["gui"] = "GUI";
|
capitalize_string_remaps["gui"] = "GUI";
|
||||||
capitalize_string_remaps["hdr"] = "HDR";
|
capitalize_string_remaps["hdr"] = "HDR";
|
||||||
capitalize_string_remaps["hidpi"] = "hiDPI";
|
capitalize_string_remaps["hidpi"] = "hiDPI";
|
||||||
|
capitalize_string_remaps["hipass"] = "High-pass";
|
||||||
|
capitalize_string_remaps["hsv"] = "HSV";
|
||||||
capitalize_string_remaps["http"] = "HTTP";
|
capitalize_string_remaps["http"] = "HTTP";
|
||||||
|
capitalize_string_remaps["id"] = "ID";
|
||||||
capitalize_string_remaps["ik"] = "IK";
|
capitalize_string_remaps["ik"] = "IK";
|
||||||
|
capitalize_string_remaps["igd"] = "IGD";
|
||||||
capitalize_string_remaps["ios"] = "iOS";
|
capitalize_string_remaps["ios"] = "iOS";
|
||||||
|
capitalize_string_remaps["iod"] = "IOD";
|
||||||
|
capitalize_string_remaps["ip"] = "IP";
|
||||||
|
capitalize_string_remaps["ipv6"] = "IPv6";
|
||||||
|
capitalize_string_remaps["k1"] = "K1";
|
||||||
|
capitalize_string_remaps["k2"] = "K2";
|
||||||
capitalize_string_remaps["kb"] = "(KB)"; // Unit.
|
capitalize_string_remaps["kb"] = "(KB)"; // Unit.
|
||||||
capitalize_string_remaps["lod"] = "LOD";
|
capitalize_string_remaps["lod"] = "LOD";
|
||||||
|
capitalize_string_remaps["lowpass"] = "Low-pass";
|
||||||
capitalize_string_remaps["macos"] = "macOS";
|
capitalize_string_remaps["macos"] = "macOS";
|
||||||
|
capitalize_string_remaps["mb"] = "(MB)"; // Unit.
|
||||||
|
capitalize_string_remaps["ms"] = "(ms)"; // Unit
|
||||||
|
// Not used for now as AudioEffectReverb has a `msec` property.
|
||||||
|
//capitalize_string_remaps["msec"] = "(msec)"; // Unit.
|
||||||
capitalize_string_remaps["msaa"] = "MSAA";
|
capitalize_string_remaps["msaa"] = "MSAA";
|
||||||
|
capitalize_string_remaps["normalmap"] = "Normal Map";
|
||||||
|
capitalize_string_remaps["opengl"] = "OpenGL";
|
||||||
capitalize_string_remaps["opentype"] = "OpenType";
|
capitalize_string_remaps["opentype"] = "OpenType";
|
||||||
capitalize_string_remaps["openxr"] = "OpenXR";
|
capitalize_string_remaps["openxr"] = "OpenXR";
|
||||||
capitalize_string_remaps["png"] = "PNG";
|
capitalize_string_remaps["png"] = "PNG";
|
||||||
capitalize_string_remaps["po2"] = "(Power of 2)"; // Unit.
|
capitalize_string_remaps["po2"] = "(Power of 2)"; // Unit.
|
||||||
capitalize_string_remaps["pvs"] = "PVS";
|
capitalize_string_remaps["pvs"] = "PVS";
|
||||||
capitalize_string_remaps["pvrtc"] = "PVRTC";
|
capitalize_string_remaps["pvrtc"] = "PVRTC";
|
||||||
|
capitalize_string_remaps["rid"] = "RID";
|
||||||
|
capitalize_string_remaps["rmb"] = "RMB";
|
||||||
|
capitalize_string_remaps["rpc"] = "RPC";
|
||||||
capitalize_string_remaps["s3tc"] = "S3TC";
|
capitalize_string_remaps["s3tc"] = "S3TC";
|
||||||
capitalize_string_remaps["sdf"] = "SDF";
|
capitalize_string_remaps["sdf"] = "SDF";
|
||||||
capitalize_string_remaps["sdfgi"] = "SDFGI";
|
capitalize_string_remaps["sdfgi"] = "SDFGI";
|
||||||
capitalize_string_remaps["sdk"] = "SDK";
|
capitalize_string_remaps["sdk"] = "SDK";
|
||||||
|
capitalize_string_remaps["sec"] = "(sec)"; // Unit.
|
||||||
capitalize_string_remaps["ssao"] = "SSAO";
|
capitalize_string_remaps["ssao"] = "SSAO";
|
||||||
capitalize_string_remaps["ssh"] = "SSH";
|
capitalize_string_remaps["ssh"] = "SSH";
|
||||||
capitalize_string_remaps["ssil"] = "SSIL";
|
capitalize_string_remaps["ssil"] = "SSIL";
|
||||||
|
@ -133,6 +162,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
|
||||||
capitalize_string_remaps["ui"] = "UI";
|
capitalize_string_remaps["ui"] = "UI";
|
||||||
capitalize_string_remaps["url"] = "URL";
|
capitalize_string_remaps["url"] = "URL";
|
||||||
capitalize_string_remaps["urls"] = "URLs";
|
capitalize_string_remaps["urls"] = "URLs";
|
||||||
|
capitalize_string_remaps["us"] = "(µs)"; // Unit.
|
||||||
capitalize_string_remaps["usec"] = "(µsec)"; // Unit.
|
capitalize_string_remaps["usec"] = "(µsec)"; // Unit.
|
||||||
capitalize_string_remaps["uv"] = "UV";
|
capitalize_string_remaps["uv"] = "UV";
|
||||||
capitalize_string_remaps["uv1"] = "UV1";
|
capitalize_string_remaps["uv1"] = "UV1";
|
||||||
|
@ -147,6 +177,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
|
||||||
capitalize_string_remaps["xr"] = "XR";
|
capitalize_string_remaps["xr"] = "XR";
|
||||||
capitalize_string_remaps["xy"] = "XY";
|
capitalize_string_remaps["xy"] = "XY";
|
||||||
capitalize_string_remaps["xz"] = "XZ";
|
capitalize_string_remaps["xz"] = "XZ";
|
||||||
|
capitalize_string_remaps["yz"] = "YZ";
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorPropertyNameProcessor::~EditorPropertyNameProcessor() {
|
EditorPropertyNameProcessor::~EditorPropertyNameProcessor() {
|
||||||
|
|
|
@ -2535,7 +2535,7 @@ ProjectManager::ProjectManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRANSLATORS: This refers to the application where users manage their Godot projects.
|
// TRANSLATORS: This refers to the application where users manage their Godot projects.
|
||||||
DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager"));
|
DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager", "Application"));
|
||||||
|
|
||||||
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
|
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/python
|
#!/bin/python
|
||||||
|
|
||||||
|
import enum
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -63,22 +64,30 @@ msgstr ""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractType(enum.IntEnum):
|
||||||
|
TEXT = 1
|
||||||
|
PROPERTY_PATH = 2
|
||||||
|
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 = {
|
message_patterns = {
|
||||||
re.compile(r'RTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): False,
|
re.compile(r'RTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
|
||||||
re.compile(r'TTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): False,
|
re.compile(r'TTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
|
||||||
re.compile(r'TTRC\("(?P<message>(?:[^"\\]|\\.)*)"\)'): False,
|
re.compile(r'TTRC\("(?P<message>(?:[^"\\]|\\.)*)"\)'): ExtractType.TEXT,
|
||||||
re.compile(
|
re.compile(
|
||||||
r'TTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
|
r'TTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
|
||||||
): False,
|
): ExtractType.TEXT,
|
||||||
re.compile(
|
re.compile(
|
||||||
r'RTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
|
r'RTRN\("(?P<message>(?:[^"\\]|\\.)*)", "(?P<plural_message>(?:[^"\\]|\\.)*)",[^,)]+?(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'
|
||||||
): False,
|
): ExtractType.TEXT,
|
||||||
re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): True,
|
re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
|
||||||
re.compile(r'GLOBAL_DEF(?:_RST)?\("(?P<message>[^".]+?)",'): True,
|
re.compile(r'GLOBAL_DEF(?:_RST)?\("(?P<message>[^".]+?)",'): ExtractType.PROPERTY_PATH,
|
||||||
re.compile(r'EDITOR_DEF(?:_RST)?\("(?P<message>[^"]+?)",'): True,
|
re.compile(r'EDITOR_DEF(?:_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
|
||||||
re.compile(r'ADD_PROPERTY\(PropertyInfo\(Variant::[A-Z]+,\s*"(?P<message>[^"]+?)",'): True,
|
re.compile(
|
||||||
re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)",'): False,
|
r'ADD_PROPERTY\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]'
|
||||||
|
): ExtractType.PROPERTY_PATH,
|
||||||
|
re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,6 +248,7 @@ def process_file(f, fname):
|
||||||
reading_translator_comment = False
|
reading_translator_comment = False
|
||||||
is_block_translator_comment = False
|
is_block_translator_comment = False
|
||||||
translator_comment = ""
|
translator_comment = ""
|
||||||
|
current_group = ""
|
||||||
|
|
||||||
while l:
|
while l:
|
||||||
|
|
||||||
|
@ -257,22 +267,30 @@ def process_file(f, fname):
|
||||||
translator_comment = translator_comment[:-1] # Remove extra \n at the end.
|
translator_comment = translator_comment[:-1] # Remove extra \n at the end.
|
||||||
|
|
||||||
if not reading_translator_comment:
|
if not reading_translator_comment:
|
||||||
for pattern, is_property_path in message_patterns.items():
|
for pattern, extract_type in message_patterns.items():
|
||||||
for m in pattern.finditer(l):
|
for m in pattern.finditer(l):
|
||||||
location = os.path.relpath(fname).replace("\\", "/")
|
location = os.path.relpath(fname).replace("\\", "/")
|
||||||
if line_nb:
|
if line_nb:
|
||||||
location += ":" + str(lc)
|
location += ":" + str(lc)
|
||||||
|
|
||||||
groups = m.groupdict("")
|
captures = m.groupdict("")
|
||||||
msg = groups.get("message", "")
|
msg = captures.get("message", "")
|
||||||
msg_plural = groups.get("plural_message", "")
|
msg_plural = captures.get("plural_message", "")
|
||||||
msgctx = groups.get("context", "")
|
msgctx = captures.get("context", "")
|
||||||
|
|
||||||
if is_property_path:
|
if extract_type == ExtractType.TEXT:
|
||||||
|
_add_message(msg, msg_plural, msgctx, location, translator_comment)
|
||||||
|
elif extract_type == ExtractType.PROPERTY_PATH:
|
||||||
|
if current_group:
|
||||||
|
if msg.startswith(current_group):
|
||||||
|
msg = msg[len(current_group) :]
|
||||||
|
else:
|
||||||
|
current_group = ""
|
||||||
for part in msg.split("/"):
|
for part in msg.split("/"):
|
||||||
_add_message(_process_editor_string(part), msg_plural, msgctx, location, translator_comment)
|
_add_message(_process_editor_string(part), msg_plural, msgctx, location, translator_comment)
|
||||||
else:
|
elif extract_type == ExtractType.GROUP:
|
||||||
_add_message(msg, msg_plural, msgctx, location, translator_comment)
|
_add_message(msg, msg_plural, msgctx, location, translator_comment)
|
||||||
|
current_group = captures["prefix"]
|
||||||
translator_comment = ""
|
translator_comment = ""
|
||||||
|
|
||||||
l = f.readline()
|
l = f.readline()
|
||||||
|
|
Loading…
Reference in a new issue