Skip to content

Commit

Permalink
Extract theme property names for localization
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyqiu authored and gaudecker committed Apr 2, 2022
1 parent 1338036 commit ced5b5d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions editor/editor_property_name_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,23 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["bvh"] = "BVH";
capitalize_string_remaps["ca"] = "CA";
capitalize_string_remaps["cd"] = "CD";
capitalize_string_remaps["commentfocus"] = "Comment Focus";
capitalize_string_remaps["cpu"] = "CPU";
capitalize_string_remaps["csg"] = "CSG";
capitalize_string_remaps["db"] = "dB";
capitalize_string_remaps["defaultfocus"] = "Default Focus";
capitalize_string_remaps["defaultframe"] = "Default Frame";
capitalize_string_remaps["dof"] = "DoF";
capitalize_string_remaps["dpi"] = "DPI";
capitalize_string_remaps["dtls"] = "DTLS";
capitalize_string_remaps["eol"] = "EOL";
capitalize_string_remaps["erp"] = "ERP";
capitalize_string_remaps["etc"] = "ETC";
capitalize_string_remaps["etc2"] = "ETC2";
capitalize_string_remaps["fbx"] = "FBX";
capitalize_string_remaps["fbx2gltf"] = "FBX2glTF";
capitalize_string_remaps["fft"] = "FFT";
capitalize_string_remaps["fg"] = "FG";
capitalize_string_remaps["fov"] = "FOV";
capitalize_string_remaps["fps"] = "FPS";
capitalize_string_remaps["fs"] = "FS";
Expand All @@ -145,6 +151,8 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["hdr"] = "HDR";
capitalize_string_remaps["hidpi"] = "hiDPI";
capitalize_string_remaps["hipass"] = "High-pass";
capitalize_string_remaps["hl"] = "HL";
capitalize_string_remaps["hseparation"] = "H Separation";
capitalize_string_remaps["hsv"] = "HSV";
capitalize_string_remaps["html"] = "HTML";
capitalize_string_remaps["http"] = "HTTP";
Expand Down Expand Up @@ -177,6 +185,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["msaa"] = "MSAA";
capitalize_string_remaps["nfc"] = "NFC";
capitalize_string_remaps["normalmap"] = "Normal Map";
capitalize_string_remaps["ofs"] = "Offset";
capitalize_string_remaps["ok"] = "OK";
capitalize_string_remaps["opengl"] = "OpenGL";
capitalize_string_remaps["opentype"] = "OpenType";
Expand All @@ -195,6 +204,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["sdfgi"] = "SDFGI";
capitalize_string_remaps["sdk"] = "SDK";
capitalize_string_remaps["sec"] = "(sec)"; // Unit.
capitalize_string_remaps["selectedframe"] = "Selected Frame";
capitalize_string_remaps["sms"] = "SMS";
capitalize_string_remaps["srgb"] = "sRGB";
capitalize_string_remaps["ssao"] = "SSAO";
Expand All @@ -203,6 +213,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["ssl"] = "SSL";
capitalize_string_remaps["stderr"] = "stderr";
capitalize_string_remaps["stdout"] = "stdout";
capitalize_string_remaps["sv"] = "SV";
capitalize_string_remaps["svg"] = "SVG";
capitalize_string_remaps["tcp"] = "TCP";
capitalize_string_remaps["ui"] = "UI";
Expand All @@ -216,9 +227,11 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["uv1"] = "UV1";
capitalize_string_remaps["uv2"] = "UV2";
capitalize_string_remaps["uwp"] = "UWP";
capitalize_string_remaps["vadjust"] = "V Adjust";
capitalize_string_remaps["vector2"] = "Vector2";
capitalize_string_remaps["vpn"] = "VPN";
capitalize_string_remaps["vram"] = "VRAM";
capitalize_string_remaps["vseparation"] = "V Separation";
capitalize_string_remaps["vsync"] = "V-Sync";
capitalize_string_remaps["wap"] = "WAP";
capitalize_string_remaps["webp"] = "WebP";
Expand Down
10 changes: 9 additions & 1 deletion editor/translations/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import enum
import fnmatch
import os
import os.path
import re
import shutil
import subprocess
Expand Down Expand Up @@ -128,6 +129,9 @@ class ExtractType(enum.IntEnum):
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().
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const {
void Control::_get_property_list(List<PropertyInfo> *p_list) const {
Ref<Theme> theme = Theme::get_default();

p_list->push_back(PropertyInfo(Variant::NIL, "Theme Overrides", PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP));
p_list->push_back(PropertyInfo(Variant::NIL, TTRC("Theme Overrides"), PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP));

{
List<StringName> names;
Expand Down

0 comments on commit ced5b5d

Please sign in to comment.